Has someone tried the 26.3 Ticket price exercise? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Has someone tried the 26.3 Ticket price exercise?

This is a practice from the Py for beginners. I have the following code Total = 0 i = 0 while True: x = input() i = i + 1 if int(x) >= 3: Total = Total + 100 elif int(x) < 3: continue elif i == 5: break print(Total) It doesn't matter how I rearrange it. It always show me an error for the input line. Traceback (most recent call last:) File "/usercode/file0.py", line 5, in <module> EOFError: EOF when reading a line Could someone tell me what it means or what I'm doing wrong, pls?

2nd May 2021, 11:03 PM
Yazmín Rendón
Yazmín Rendón - avatar
9 Answers
+ 2
total = 0 x1 = int(input()) x2 = int(input()) x3 = int(input()) x4 = int(input()) x5 = int(input()) ages = [x1, x2, x3, x4, x5] for age in ages: if age < 3: continue else: total += 100 print(total)
25th May 2021, 4:39 PM
Laurent
Laurent - avatar
+ 2
Hi Yazmín Rendón The spam comment was not directed at you, but at the person who has since removed their comment. The faces above my comment is the user_name of that person. PS: I am glad you have resolved the problem
23rd Aug 2021, 11:32 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Yazmín Rendón The problem us that Sololearn needs all of it's inputs entered before RUN is hit. Try a scenario where you enter a series of numbers that will meet the condition of your code.
2nd May 2021, 11:42 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
🤣😔🤩🥸🙂🤨🥰😘🙃😚🤨🤣😛😋🙃😋😋🤣😘🥳😟😘😔😘😟 if you keep spamming the Q&A thread, you will be banned. Please reserve the Q&A for coding related questions.
2nd May 2021, 11:49 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
I don't know the details for the questions as I am not a Pro user, but I think it's throwing EOF because the while loop never breaks. Your conditional checking checks for x >= 3 first so it will always evaluate to true, so if i is 5 but x is bigger than 3 it wil still evaluate to true thus running the code Total = Total + 100. This happens because python is an interpreted language, meaning it reads and executes code per line and doesn't read the code as a whole at execution. The fix I might recommend is checking if x < 3 first, then i == 5, then x >= 3. Like so if int(x) < 3: continue elif i== 5: break elif int(x) >= 3: Total = Total + 100 OR you can separate the condition check for variable x and i, like so : if int(x) <= 3: continue elif int(x) >= 3: Total = Total + 100 if i == 5: break Hope this helps
3rd May 2021, 12:07 AM
Dama Dhananjaya Daliman
Dama Dhananjaya Daliman - avatar
+ 1
Thank all for your answers and sorry for the late reply 🙈 It helped me to solve it, it was a nonsense. It was related to the way I was writing the code. The condition set asks for 6 inputs, but the exercise only provides 5 inputs, for that reason I was getting that error.
23rd Aug 2021, 10:16 PM
Yazmín Rendón
Yazmín Rendón - avatar
+ 1
Rik Wittkopp I don't see it as spam, it is more like sharing info 🤭🤭
23rd Aug 2021, 10:18 PM
Yazmín Rendón
Yazmín Rendón - avatar
0
assalamulai Kum ...Hello mam can you help me solf this question i don't understand plz help me 😓😓🙏 Coding list x = input () Print (x+10) Output Print (x*10)
23rd Apr 2022, 5:36 PM
GøĐ GïfŤ
GøĐ GïfŤ - avatar
0
Traceback (most recent call last): File "/usercode/file0.py", line 4, in <module> x = int(input()) EOFError: EOF when reading a line my solution total = 0 x=0 while x <5: age = int (input()) if age >3: total =+ 100 x +=1 print(total) please help solve the line 4 if am doing something wrong and everything else am missing. Your help is appreciate thanks
12th Aug 2022, 11:19 AM
Kgotso Malefetse