一个循环不断地用==或函数中断,即使该循环应该继续进行也是如此,以便玩家可以滚动。我无法找到为什么有人可以帮助我。那就太好了。
elif roll1 is roll2:
print(score1)
continue
或
elif roll1 == roll2:
print(score1)
continue
它们都不起作用,所以没人知道为什么。
while True:
print(" ")
input("Press enter to roll player 1 ")
print("Rolling dice!")
roll1=random.randint(1,6)
roll2=random.randint(1,6)
print(roll1)
print(roll2)
total=(roll1 + roll2)
print("Your total is:" ,total)
score1=score1 +total
even = [2,4,6,8,10,12]
odd = [3,5,7,9,11]
if total in even:
score1=score1 +10
print(score1)
break
elif total in odd:
score1=score1 -5
print(score1)
break
elif roll1 == roll2:
print(score1)
continue
有完整的循环
答案 0 :(得分:0)
问题在这里:
if total in even:
score1=score1 +10
print(score1)
break
elif total in odd:
score1=score1 -5
print(score1)
break
elif roll1 == roll2:
print(score1)
continue
您将永远不会到达最后一个省略号,因为总数始终在even
或odd
中。如果要先重新滚动,则应将Elif上移至类似以下内容:
if roll1 == roll2:
print(score1)
continue
elif total in odd:
score1=score1 -5
print(score1)
break
elif total in even:
score1=score1 +10
print(score1)
break