我正在尝试使用 while 循环和 if 来创建骰子游戏。我已经成功完成了这项工作,但是我正在尝试弄清楚如何对游戏进行编程,以便如果未输入数字 4,6 或 12,它将表明选择无效并再次询问 diceChoice。有人可以帮忙吗?
到目前为止,我已经...
rollAgain = "Yes" or "yes" or "y"
while rollAgain == "Yes" or "yes" or "y":
diceChoice = input ("Which dice would you like to roll; 4 sided, 6, sided or 12 sided?")
if diceChoice == "4":
import random
print("You rolled a ", random.randint(1,4))
if diceChoice == "6":
import random
print("You rolled a ", random.randint(1,6))
if diceChoice == "12":
import random
print("You rolled a ", random.randint(1,12))
rollAgain = input ("Roll Again?")
print ("Thank you for playing")