Need help on Ticketing System. Anyone? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Need help on Ticketing System. Anyone?

You are making a ticketing system. The price of a single ticket is $100. For children under 3 years old, the ticket is free. Your program needs to take the ages of 5 passengers as input and output the total price for their tickets. What I am writing is: total = 0 passengers = 0 while passengers <=5: age = int(input()) if (age == 3): continue total += 100 passengers += 1 print (total) Error I am getting is EOF error in line 4. What’s that? And are the other statements correct?

29th Oct 2021, 1:00 PM
Abhinay Kumar Singh
4 Answers
+ 4
you put the total and passengers vars within the if-statement so it takes more than 5 passengers which is not correct. here is my code total = 0 passengers = 0 while passengers < 5: age = int(input('enter age: ')) passengers += 1 if age <= 3: continue total += 100 print(total)
29th Oct 2021, 1:38 PM
Krishnam Raju M
Krishnam Raju M - avatar
+ 3
Code's fine. But when you start at an index of 0 and go until you are past 5, that's 6 values and it only is giving 5. So it hangs on that last iteration when it tries to grab input while passengers < 5:
29th Oct 2021, 1:13 PM
Slick
Slick - avatar
0
Krishnam Raju M Ohh alright. The system has to count the passenger even if s/he is less than 3 years old, just need not add the amount. Now it worked, after also correcting the age condition!! thanks buddy 😃
29th Oct 2021, 1:54 PM
Abhinay Kumar Singh
0
Slick : got it now.. thanks 😃
29th Oct 2021, 1:57 PM
Abhinay Kumar Singh