0
New memory in python programming......Could someone tell me where is my fault ?
https://code.sololearn.com/cKNw0PwLk485/?ref=app from random import randint number = randint(0,99) guess = -1 while guess != number: guess = input("Guess a Number: ") if guess > number: print ("Too high") elif guess < number: print ("Too low") print ("Just right")
4 Réponses
+ 3
guess=int(input('Guess A Number')
That Should Do It
here the problem is python thinks that guess
is a string ...so it cannot be compared with a number
here we convert the guess into integer by using the int method.
:)
+ 1
python 2 is different
personal opinion: i am in love with python3
0
input() returns a string, you have to convert it to a number using the int() method.
0
working, thanks for both idea.....
but why is this possible when I use the same code in a different compiler it works, ex.. in python 2 ?