samedi 28 avril 2018

My if statement always does the not equal, even if the answer is equal

It always turn out to print out "Sorry", even if the number is the same. Why doesn't this if statement work?

    import random

    high_number = input("What is the maximum number?\nExample(20): ")  
    print('0-{}'.format(high_number))  

    guess = input("Guess the number: ")  
    high_number = int(high_number)  

    value = random.randint(0, high_number)  

    if value != guess:  
       print("Sorry.")  
    elif value == guess:  
       print("Hurray!")  

Aucun commentaire:

Enregistrer un commentaire