Pls help / EOF Error in assignment | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Pls help / EOF Error in assignment

Hey, I tried to complete one of the assignments but receive an EOFError for the line “n=int ...” The line was already given by the assignment and I don’t know what’s wrong. Are you able to help? Don’t know a lot about coding yet 🙈 items = [] while True: n = int(input()) if (items)==0: break items.append(n) print(items)

11th Nov 2020, 9:49 PM
Jeaninne Jendro
Jeaninne Jendro - avatar
3 Answers
+ 5
You have to keep entering inputs until your break statement (which should also throw an error) is met. My example: items = [] while 1: n = int(input()) items.append(n) if len(items) == 2: break print(items) Enter input like this: 3 4 You should also find out how inputs are handled here on SoloLearn. Happy Coding 😀
11th Nov 2020, 10:03 PM
Tomiwa Joseph
Tomiwa Joseph - avatar
+ 1
In that case if n==0 : break works fine. Not give EOF error. But items.append(n) is not indented properly to work in loop. So that may causing failure. What error you getting actually..?
11th Nov 2020, 10:44 PM
Jayakrishna 🇮🇳
0
Thanks for the quick reply. The task is to end the loop when the input is 0, therefore I would use if n==0: what is wrong with that statement that I get an EOF Error and how would that work correctly? The input is given by Sololearn.
11th Nov 2020, 10:14 PM
Jeaninne Jendro
Jeaninne Jendro - avatar