Jae Song
Jae Song

Reputation: 29

while loop is not running correctly

In my code for guessing game, even when the guess is 1, it returns that the guess is too high. Cant figure it out. Thanks!

Upvotes: 0

Views: 57

Answers (2)

Stephen
Stephen

Reputation: 1446

Essentially you should not be using raw_input as this will get you a string and not an integer. Try using input

Please see this question for more details: Python read input as integers

Upvotes: 1

Marcin
Marcin

Reputation: 239005

Your guessNum is string. Need to make it to int when ever you expect a user to input an integer. For example:

guessNum = int(raw_input('Enter a number between 1 and 100: '))

Upvotes: 0

Related Questions