samedi 12 septembre 2020

Problem with Python code running if and elif statements

another simple problem that I'am having trouble with. If I run the below code and type 8, or 9 as the input, the code returns the correct response. Once I type larger numbers such as 10, 20 it just returns "I have more socks than you" Is this something to do with int and str values or have I just messed up the code. Please explain in laymans terms.

 my_socks = "7"

 user_input = input("How many socks do you have?")

 if user_input < my_socks:
    print("I have more socks than you!")
 elif user_input > my_socks:
    print("You have more socks than me!")

Many thanks

Aucun commentaire:

Enregistrer un commentaire