0
Ticket Prices Practice Test - Help!!!
total = 0 num_tickets = 0 while (num_tickets <=5): age = int(input()) if (age > 3): total += 100 elif (age <= 3 and age >=0): continue num_tickets+=1 print(total) Why is this code printing out EOFError? Anyone with an alternative solution for the Ticket Prices Practice Test should kindly share it with me
5 Answers
0
Found it the âincrementâ should have come before âageâ variable. This way:
total = 0
num_tickets = 1
while (num_tickets <=5):
num_tickets+=1
age = int(input())
if (age > 3):
total += 100
elif (age <= 3 and age >=0):
continue
print(total)
+ 2
You can remove the elif statement. It causes the problem.
+ 1
If you need to take 5 valid ages of above 3 then it must be num_tickets<5
Not <=
+ 1
That's true, thank you
I changed the initial value of num_tickets from 0 to 1 but it still doesn't work
+ 1
It means, you have only 5 inputs then. And in your edit, your elif condition and continue has no use. You can delete that. Better you posted description. But fine if it is completed..!