[Python] Submitted number does not register with random number?

Discussão em 'Python' iniciado por Stack, Março 2, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to make a simple program where the user submits 10 numbers between 1 and 20 to try and find the random number.

    The problem is that even if the user submits a number that matches the random number it doesn't register. How can I solve this?

    Here is my code:

    import random
    number = random.randint(1,20)
    guesses = []

    for i in range (1,11):
    guesses.append(int(input("Submit number {} : ".format(i))))

    for guess in guesses:
    if guess == number:
    print("Bingo!")
    print("The random number was: ", number)
    break
    else:
    print("Sorry, no bingo today...")
    print("The random number was: ", number)
    break


    I have tried different loops and what not, but it doesn't seem to work.

    Continue reading...

Compartilhe esta Página