我正在编写一个模拟模拟游戏,以便更好地理解python的基础知识,但...... 它会抛出一个Traceback错误。 如果你能协助我解决这个问题,将不胜感激。
import random
def DiceSize():
DieSize= int(input("""Please pick a dice size,
4 Sides
6 Sides
12 Sides"""))
if not (DieSize == 4 or DieSize == 6 or DieSize == 12):
print("Thats not right!")
DiceSize()
else:
print("You have picked %i" % DieSize)
RollDice()
def RollDice():
if DieSize == 4:
min = 1
max = 4
print("ROLLING")
print (random.randint(min, max))
RollAgain()
elif DieSize == 6:
min = 1
max = 6
print("ROLLING")
print(random.randint(min, max))
RollAgain()
else:
min = 1
max = 12
print("ROLLING")
print(random.randint(min, max))
RollAgain()
def RollAgain():
roll_again = input("Do you want to roll again: ").lower()
if roll_again == "y":
DiceSize()
else:
print()
DiceSize()
答案 0 :(得分:0)
你的问题是你没有通过模糊
RollDice(DieSize)
def RollDice(DieSize):