【发布时间】:2021-06-16 16:22:25
【问题描述】:
我正在做一个掷骰子的游戏。以下代码会产生错误,提示“在循环外继续”:
import random
repeat="y" or "yes"
while repeat == "y" or "yes"
print("Rolling the dice")
print(random.randint(1,6))
repeat = input("Do you wanna roll again Y/N?").lower()
if repeat =="y" or "yes":
continue
else:
print("Thanks for rolling")
break
为什么会出现这个错误?
【问题讨论】:
-
我已经从您的屏幕截图中转录了您的代码,以便其他人可以阅读。我们更喜欢将问题中的代码作为文本而不是外部图像。
标签: python dice rolling-computation