Why n in while loop are EOFError | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why n in while loop are EOFError

Hi, I practice in topic of break in while loop and I write code for this: items = [] while True: n = int(input()) if n != 0 : items.append(n) else: break print(items) when I run this code. I got error n = int(input()) EOFError: EOF when reading a line I dont know why it error. Anyone can help me?

21st Oct 2021, 7:38 PM
Thada Sukprasong
Thada Sukprasong - avatar
7 Answers
+ 5
The code is fine. Just remember that you have to input all numbers at once
21st Oct 2021, 7:43 PM
Lisa
Lisa - avatar
+ 1
Why practice? Input all numbers in the window like this 3 4 0 Then submit
21st Oct 2021, 7:54 PM
Lisa
Lisa - avatar
+ 1
Which task is it in the course?
21st Oct 2021, 8:03 PM
Lisa
Lisa - avatar
0
yeah, But in this this practice no anyone got the same problem, I try to copy code from other people and it not work, I got the same problem.
21st Oct 2021, 7:49 PM
Thada Sukprasong
Thada Sukprasong - avatar
0
I can't input number by myself becuase I learn 'python core' it course in this app.
21st Oct 2021, 7:58 PM
Thada Sukprasong
Thada Sukprasong - avatar
0
Infinite loop (task in pro user) in topic control structure
21st Oct 2021, 8:59 PM
Thada Sukprasong
Thada Sukprasong - avatar
0
the code is working properly. may be it's the tool problem i mean IDLE interpreter problem. which IDLE you are using? please check the the tool you are using
22nd Oct 2021, 2:08 PM
Krishnam Raju M
Krishnam Raju M - avatar