New memory in python programming......Could someone tell me where is my fault ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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")

14th Apr 2017, 7:00 PM
Marta walter
Marta walter - avatar
4 Answers
+ 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. :)
14th Apr 2017, 7:56 PM
Nihad TK
Nihad TK - avatar
+ 1
python 2 is different personal opinion: i am in love with python3
14th Apr 2017, 8:27 PM
Nihad TK
Nihad TK - avatar
0
input() returns a string, you have to convert it to a number using the int() method.
14th Apr 2017, 7:03 PM
merkrafter
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 ?
14th Apr 2017, 8:10 PM
Marta walter
Marta walter - avatar