首页 > 解决方案 > Python Lotto 模拟随机错误发生

问题描述

我为一个学校项目做了一个 python 乐透模拟。我终于完成了它并且它可以工作,只是当用户要求计算机生成数字时发生随机错误。如果您尝试代码并在按“1”让计算机生成后继续重新启动程序,您将遇到相同的错误。我只是想要一些帮助来解决这个错误,也许还有我可以对代码进行的调整。

谢谢

错误:

Traceback (most recent call last):
  File "D:\Lotto\combined.py", line 154, in <module>
    start()
  File "D:\Lotto\combined.py", line 148, in start
    computer_generates()
  File "D:\Lotto\combined.py", line 83, in computer_generates
    list_of_Num_2[-1].append(x) #Loop and take the first number in list [-1] and add to list
AttributeError: 'int' object has no attribute 'append'

Github 上的 Python Lotto 模拟代码

标签: pythonsimulation

解决方案


推荐阅读