【发布时间】:2017-03-05 14:57:46
【问题描述】:
我正在尝试为我的侄子制作掷骰子,这样他就可以在没有骰子的情况下玩棋盘游戏。即使我输入了一个正确的条件,我也陷入了一个while循环。我试图让他选择他想使用的骰子,但如果他选择了错误的骰子,那么它会要求他再次输入。我的代码是...
dice_select = input('Enter the amount of sides are on the dice you want to throw, either 4, 6, or 12: ')
while dice_select != 4 or dice_select != 6 or dice_select != 12:
dice_select = int(input('Sorry thats not quite right. Enter the amount of sides are on the dice you want to throw, either 4, 6, or 12: '))
如果我输入 4、6 或 12,那么当它应该继续时,它仍然会让我进入循环。
【问题讨论】:
-
条件为假的唯一方法是
dice_select同时等于 4、6 和 12。 -
重新阅读您的情况。根据您寻求的价值对其进行评估。当
dice_select是4时会发生什么?
标签: python loops while-loop numbers int