[Python] What's the issue with my lottery simulator?

Discussão em 'Python' iniciado por Stack, Janeiro 20, 2025.

  1. Stack

    Stack Membro Participativo

    I want to simulate how often you'd have to play the lottery for a win:

    import random

    lotterylist = [random.randint(1, 49) for x in range(6)]

    winning_numbers = [6, 26, 31, 32, 33, 49]

    counter = 0

    while winning_numbers != lotterylist:
    lotterylist = [random.randint(1, 49) for x in range(6)]

    counter += 1

    print("Finished! I got", counter, "tries to win.")


    I ran the program for 1.5 hours and it still ran. Does it only work if the generated list has the numbers also in the exact same row so only 6, 26, 31, 32, 33, 49 would work and not 49, 33, 32, 31, 26, 6? If yes, how can I fix that?

    Continue reading...

Compartilhe esta Página