我想我的程序已经完成,但是......它不起作用.我正在尝试编写一个模拟彩票游戏的程序,但是当我尝试检查用户对机票上猜测数量的猜测时,我得到一个错误,告诉我"列表索引超出范围".我认为它与代码的一部分有关,我将随机数分配给"a","b","c"等.但我不确定.
以下是完整的代码:
import random
def main():
random.seed()
#Prompts the user to enter the number of tickets they wish to play.
tickets = int(input("How many lottery tickets do you want?\n"))
#Creates the dictionaries "winning_numbers" and "guess." Also creates the variable "winnings" for total amount of money won.
winning_numbers = []
guess = []
winnings = 0
#Generates the winning lotto numbers.
for i in range(tickets):
del winning_numbers[:]
a = random.randint(1,30)
while not (a in winning_numbers):
winning_numbers.append(a)
b = random.randint(1,30)
while not …Run Code Online (Sandbox Code Playgroud)