Error when running my code from code playground, but not from local IDLE. Please Help! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Error when running my code from code playground, but not from local IDLE. Please Help!

Hi all, I am trying to add new code to 'My Codes', but when I run the code I get the following error; Guess my number 1-20: Too low, try again: Traceback (most recent call last): File "./Playground/file0.py", line 8, in <module> guess=input() EOFError: EOF when reading a line The code is as follows; import random num=random.randint(1,20) flag=True guess=0 print('Guess my number 1-20: ',end='') while flag == True: guess=input() if not guess.isdigit(): print('Invalid! Enter only digits 1-20') break elif int(guess) < num: print('Too low, try again:', end='') elif int(guess) > num: print('Too high, try again:', end='') else: print('Correct... My number is ' + guess) flag=False I have run this locally in IDLE 3.8 and it works, so I can only guess that it's due to the website and how it is saving/storing the code! Any ideas all, as I want to create a cool library of code for all to see! :)

4th Apr 2020, 7:34 AM
Ricky Brooks
Ricky Brooks - avatar
3 Answers
+ 5
The code playground of sololearn can only take input once. As your 'taking input' part is under a while True loop, it could not handle the code. The foreign Environments are strong enough to take outputs several times. So it can run the infinite loop.
4th Apr 2020, 7:41 AM
M Tamim
M Tamim - avatar
+ 5
Ricky Brooks while Flage==True: is called an infinite loop. while loops execute code until its boolean condition becomes false. as the above condition is always true, it runs infinite time. So, it is called an infinite loop
4th Apr 2020, 9:08 AM
M Tamim
M Tamim - avatar
+ 1
Thank you Muntasir! Ah so 'while flag == True:' is called a loopback?
4th Apr 2020, 8:14 AM
Ricky Brooks
Ricky Brooks - avatar