on-internet
← Community

How do I make a variable detect if it is greater than or less than another one?

Stack Overflow ·

I am currently learning Python, and I decided to build a small "Guess the Number" type of game. I am using the random feature, and trying to make it so it will detect if the user's input is equal the the random number. This is my code: irand = randrange(1, 10) while True: number = input ("Pick a number 1-10: ") if number < irand: print (" ") print ("That's too high, try again.") if number > irand: print (" ") print ("That's too low, try again.") if number == irand: print (" ") print ("You got it right! You won!") break I am not exactly sure how to make it detect if number is equal to, less tha

Comments

Sign in or sign up to comment and upvote.

No comments yet.