# Problem solving, needed nudge, help

You are making a ticketing system.
The price of a single ticket is \$100.
For children under 3 years of age, the ticket is free.

Your program needs to take the ages of 5 passengers as input and output the total price for their tickets.

Sample Input
18
24
2
5
42

Sample Output
400

There is one child under 3 among the passengers, so the total price of 5 tickets is \$400 .

My code so far

total = 0
ticket = 100
costumers = 5
age = int(input("Enter age: "))
while costumers > 1:
costumers -= 1
if age > 5:
total += ticket
print(total)
age = int(input("Enter age: "))

This is what I did to solve that. Obviously not all groups will buy in 5s, so will take some adjustments to the coding, but for the example at hand, this is how I would do it. (Also, there might be a better way, I’m new to coding)

1 Like

This is what I found can work for any number of passengers. I could not get it to work for saying “quit” in the age input to make it end, but I was able to make it so if you type 0 it will end.

1 Like

@Andy30 new or not the second code works pretty well, from my opinion of beginner but the site Sololearn won’t accept this version of code, but thank you :D!!!