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

22nd Jan 2022, 1:26 PM
Joseph Dorman
5 Respuestas
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)
22nd Jan 2022, 7:20 PM
Joseph Dorman
+ 2
You can remove the elif statement. It causes the problem.
22nd Jan 2022, 2:15 PM
Simba
Simba - avatar
+ 1
If you need to take 5 valid ages of above 3 then it must be num_tickets<5 Not <=
22nd Jan 2022, 1:38 PM
Jayakrishna 🇮🇳
+ 1
That's true, thank you I changed the initial value of num_tickets from 0 to 1 but it still doesn't work
22nd Jan 2022, 1:43 PM
Joseph Dorman
+ 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..!
22nd Jan 2022, 7:27 PM
Jayakrishna 🇮🇳