0
Can you help me find the mistake in my code pls.?
The below code returns an EOF while reading a line exception. Please help me fix it. total = 0 #your code goes here i = 1 while i <= 5: x = int( input()) if x < 3: continue total += 100 i += 1 print(total)
4 odpowiedzi
+ 3
How Chloe already said in other words, on SL Playground you have to put all input data at the beginning of code running. For this reason and bacause the while loop will be runned 5 times your input should be:
4
2
3
8
9
+ 2
You must provide 5 inputs, all on different lines to avoid the error :)
+ 1
Also make sure input values are greater than or equal to 3. The `continue` statement will rewind execution of the loop body, to read another input. But then again, there are only limited input entries we can supply through the imput dialog.
+ 1
Hi Orang!
Inorder to handle this eof error, you can iterate the loop before the if statement. So, it will read all 5 inputs one by one. After that, you have to add an else statement to count the total properly.
Here it is your working code
total = 0
#your code goes here
i = 1
while i <= 5:
x = int( input())
i += 1
if x < 3:
continue
else:
total += 100
print(total)