0
Ticketing System Practice in Python
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. Sample Input 18 24 2 5 42 Sample Output 400 #my code goes from here: ages=input() i=0 while True: for age in ages: if ages >=3: i+=1 else: continue print (i*100) I'm getting error like " if ages >=3: TypeError: '>=' not supported between instances of 'str' and 'int'". Can anyone help here? Thank you!
1 Odpowiedź
0
You need to take 5 inputs.
You need to cast input to int to do calculations or comparisons.
"while True:" starts an endless loop that you have to stop eventually with "break".
When you iterate through an array (for loop) you should also use the iteration variable, "age" in your case.
You don't need "else: continue"