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)

22nd Aug 2021, 8:55 PM
Orang Hutan
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
22nd Aug 2021, 9:53 PM
JaScript
JaScript - avatar
+ 2
You must provide 5 inputs, all on different lines to avoid the error :)
22nd Aug 2021, 9:08 PM
Chloe
Chloe - avatar
+ 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.
22nd Aug 2021, 11:51 PM
Ipang
+ 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)
23rd Aug 2021, 11:38 AM
Python Learner
Python Learner - avatar