彩票分析

2024-04-28 20:41:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在通过Python模拟彩票分析。 我试过几种方法,但效果不好。 这是我的密码:

from random import choice

activator = True
while activator:
    numbers_letters = [5, 4, 7, 9, 0, 'A', 'S', 'H']
    prize_winner = []

    for i in range (0, 4):
        selected = choice(numbers_letters)
        prize_winner.append(selected)

    my_tickets = {5, 'S'}

    if print(my_tickets.issubset(prize_winner)) == True:
        print("You win the prize!")
        activator = False
    else:
        count = 0
        count += 1
        continue

print(f"Trying attempt : {count}")

我上一次尝试的结果是一个带有True/False的无限输出,我知道这是由于while循环没有很好地逃逸,但我不知道如何编辑它。我已经想了一个下午了,希望有人能帮我


Tags: falsetruemycountticketsprintselectednumbers