【发布时间】:2016-02-26 10:04:11
【问题描述】:
def RollTwoDice()
die1 = random.randint(1,6)
die2 = random.randint(1,6)
然后,这里有根据掷出的数字显示骰子图片的代码
然后:
print("Press \'enter\' to roll two dice
input()
myRoll=RollTwoDice
total=die1+die2
print("You rolled a total of",total)
现在骰子的显示效果很好,唯一的问题是最后一行代码。我收到此错误;
total = die1+die2
NameError: name 'die1' is not defined
当我运行 myRoll=RollTwoDice 行时,我认为 die1 和 die2 正在被定义?我做错了什么?
【问题讨论】:
-
花点时间将您的示例组合成一个工作脚本。现在你有多个错误表明你没有努力为我们发布真实的东西。目标是我们可以剪切/粘贴并自己尝试的东西。
标签: python