jeudi 29 novembre 2018

Prompting User to Guess A Number Function [duplicate]

This question already has an answer here:

The program is suppose to generate a random number between 0 and 10 and then prompt the user to guess it within five tries. But the program continuously outputs " You guessed incorrect". I've tried it out various times and it just keeps printing " You guessed incorrect" repeatedly for five tries. How do I prompt it to say " You guessed Correct" when the user has the right number?

import random
def guess():
    randNum = random.randint(0,10)
    count = 0
    while count < 5:
        count = count + 1
        number1 = input("Guess A Number")
    if number1 != randNum:
       print(" You Guessed incorrect")
    else:

        print(" You are Correct")

Aucun commentaire:

Enregistrer un commentaire