0

Why this code can’t work?

import random the_number = random.randint(1, 100) guess = int(input("Guess a number between 1 and 100: ")) while guess != the_number: if guess > the_number: print(guess, "was too high. Try again.") if guess < the_number: print(guess, "was too low. Try again.") guess = int(input("Guess again: ")) print(guess, "was the number! You win!")

9th Feb 2018, 12:08 PM
MicahMa
MicahMa - avatar
1 Odpowiedź
+ 9
It's working perfectly in python 3 locally on my device. If you mean running the code on Sololearn. you basically need to provide all the inputs at the start of your program when it prompts for it. Due to the limitations of CodePlayground it should not be run here. Try it in a python 3 interpreter locally on your device. It should work fine.
9th Feb 2018, 1:16 PM
Lord Krishna
Lord Krishna - avatar