+ 2

I don't understand why this gives an Error (EOFError)

I'm starting to learn to code so I have a problem and If you could please teach me. I was doing practice 24.2 from Python for Beginners. I had to get the total cost of all tickets and each ticket cost 100 and people under 3 yo get a free ticket. I was given 5 inputs with their age. If I run the code, I get an EOFError. I know it means End Of the File Error but i don't understand it. I did it in another way without using "continue" and it worked but still I don't know what happened here. Btw It only happens when you input a value lower than 3 Code (python): https://code.sololearn.com/ckW86K83ymw7/?ref=app

20th Aug 2022, 7:46 PM
Dragen
Dragen - avatar
3 ответов
+ 1
Your continue statement causes to skip adding total as well as I+=1 also. But you need to skip only adding to total. So now your code asks **atleast 5 input not lessthan 3 , instead just 5 inputs...
20th Aug 2022, 7:50 PM
Jayakrishna 🇮🇳
+ 5
Dragen , i would suggest you to simplify the code: > for all person where age is less than 3: we don't need to do anything, remove this part of the code > for all person where age is greater or equal than 3: we need to update the total sum > for all person whatever age they have, we need to increment the counter. this has to be done outside of the if conditional.
20th Aug 2022, 8:40 PM
Lothar
Lothar - avatar
+ 1
You need to provide all inputs in the pop-up window in the beginning as sololearn playground is not interactive. For example: 20 21 22 23 24 then hit submit button Read the text description in the pop-up window
20th Aug 2022, 7:51 PM
Lisa
Lisa - avatar