我有一个掷骰子程序的问题(现在是文本,但最终是图形)。除了我使用的 IDE Wing IDE 101 4.1 之外,它不会在任何地方工作。我得到的错误闪烁得太快,我无法阅读,但我会尝试对其进行截图。(如果我得到截图,我会编辑这篇文章。)
这是程序:
import random
#variables
available_dice = "D20"
main_pgm_start = False
#definitions of functions
def diePick():
print("Pick a die. Your choices are: ", available_dice)
print("")
which_dice = input("")
if which_dice == "D20" or which_dice == "d20":
rollD20()
else:
print("Error: Please try again")
print("")
diePick()
def rollD20():
print("Rolling D20 .... ")
print("")
d20_result = random.randrange(1, 20)
print("You have rolled a ", d20_result)
print("")
print("Would you like to roll again?")
print("")
y = input("")
if y == "y" or y == "Y" or y == "yes" or y == "Yes":
print("")
diePick()
def MainProgram():
print("Benjamin Ward's Random D&D Dice Roller")
print("")
x = input(" Press Enter to Continue")
print("")
diePick()
MainProgram()