一个循环不断地用==或is函数中断,即使它应该继续,所以玩家可以再次尝试滚动。我不明白为什么有人能帮我。那太好了。你知道吗
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
有完整的循环
问题在于:
您永远不会到达最后一个elif,因为total总是在
even
或odd
中。如果您想先重新滚动,您应该将elif上移到如下位置:相关问题 更多 >
编程相关推荐