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
我想die1和die2正在定义当我跑myRoll = RollTwoDice线?我做错了什么?
花点时间您的示例合并成一个单一的工作脚本。现在你有多个错误,表明你没有付出努力发布真实的东西给我们。我们的目标是我们可以削减/粘贴并尝试自己。 – tdelaney