0

Code error

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. total=0 passengers=5 while True: age=input() if age >3: total +=100 passengers -=1 elif age<3: passengers -=1 continue print (total) What is wrong with it

21st Nov 2021, 10:19 PM
Iakovos Xalka
Iakovos Xalka - avatar
2 Respuestas
+ 2
while True: == do this forever try it with: "while passengers:"
21st Nov 2021, 11:41 PM
Slick
Slick - avatar
+ 1
I would have went at this a bit different. Given 5 it's will be passed and all tickets are 100 if age 3 and above. total = 0 for i in range (5): age = int(input()) If age >= 3: total += 100 print(total) Also the output may need to be in $0.00 format. total = 0. 00 for i in range (5): age = float(input()) If age >= 3: total += 100.00 print("
quot; + str(total))
21st Nov 2021, 11:47 PM
William Owens
William Owens - avatar