0
I was trying this random number generator and guessing game in python but it didn't work.
I guess it happened because we can't import random library in sololearn ,I don't know just guessing. What's your take on this? This is the code import random r= random.randint (1,20) while (True): inp = int (input ()) if(inp<r): print("try typing greater number ") elif(inp>r): print ("try typing smaller number ") else: print("congo you guessed right") break ;
3 Respuestas
+ 3
random works fine on sololearn ,perhaps the loop runs forever ,you need to provide all the inputs first time only
+ 2
Limit the number of guesses instead of 'until matching'..
Llke take variable, terminate loop when limit reached
i =0
while i < 5 :
i += 1
#do next
Input 5 numbers and run program...
0
Thanks now it worked