0
I have been stucked for days on this question Python for Beginners
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 https://code.sololearn.com/ccwZCY4QFqp1 NOTE I understand i need to input age i.e age = int(input) initialise total with 100 i.e total = 100 passenger = 5 ( range should not be more than 5 passenger ) Would really appreciate any help i can get. Thanks
4 Answers
+ 1
You need to use for loop for range passanger and delete space before total+=100 like this
age = int(input())
passenger = 5
total = 100
for i in range(passenger):
if age <=3:
continue
total + 100
print (total)
Edit:
you need to move age variable to between for and if
+ 1
total = 0
while 5 > 0:
age = int(input())
if age > 3:
total += 100
print(total)
0
another way to solve :
total=0
i=1
while i<=5:
a=int(input())
if a>3:
total+=100
i+=1
print(total)