我在下面的python循环中有问题。
它不会在 totalout=4 时立即停止,而是仅在 scorein 的整个循环结束时才停止。(即第三循环)
例如,如果得分 2 中的 totalout=4,它会运行循环直到达到 10
#global value
totalturn=0
totalscorein=0
totalout=0
def main
numberofturn=int(input("Number of score:"))
no_turn=['1','2','3','4','5','6','7','8','9','10']
#while loop condition
while totalturn<numberofturn and totalout<10:
#increasement
totalscore+=1
#for loop for score
for t in range(1,numberofturn+1):
turns=s*1
print("\n\n\nThe turn"+no_turn[t]+":",turns)
#for loop for number to appear from list
for c in range (10):
#list for random number to appear
numscore = ['1','2','3','4','5','6','7','8','9','o']
#random choice from numscore list to appear
from random import choice
scorein=choice(numscore)
print ("\n\nScores :",scorein)
if scorein.isdigit():
totalscorein=totalscorein+int(scorein)
if scorein.isalpha():
totalout+=1
if totalturn==numberofturn:
print("\nTotal turn played:",totalturn)
elif totalout==4:
print("\nTotal turns played",totalturn)
break
else:
print("")