dimanche 2 septembre 2018

Incorrect if-else statements

I've been trying to write a function that will ask for a number between 1-11 and will randomly choose a number and will compare between them. I can't figure out why no matter what number I type in (equals or smaller or bigger) it will always type the "Your number is less" message.

def loto():
    _number = int(input("Enter any number between 1-10: "))
    import random
    for x in range(1):
        print ("Python chose: " + str(random.randint(1,11)))
    if ("_number" == "random"):
        print ("You Won! :)")
    elif ("_number" < "random"):
        print ("Your number is less")
    elif ("_number" > "random"):
        print ("Your number is more")
    else:
        print ("You Lost :(")

loto()

I'm using Python 3.

Thanks:)

Aucun commentaire:

Enregistrer un commentaire