+ 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?
9 odpowiedzi
+ 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)
+ 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
+ 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.
+ 1
🤣😔🤩🥸🙂🤨🥰😘🙃😚🤨🤣😛😋🙃😋😋🤣😘🥳😟😘😔😘😟
if you keep spamming the Q&A thread, you will be banned.
Please reserve the Q&A for coding related questions.
+ 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
+ 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.
+ 1
Rik Wittkopp I don't see it as spam, it is more like sharing info 🤭🤭
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)
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