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)
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 đ
+ 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..?
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.