请教python题目

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.

total = 0
#your code goes here

1 个赞
total = 0
# your code goes here

ages = [18, 24, 2, 5, 42]
for i in ages:
    if i <= 3:
        continue
    total += 100

print(total)
1 个赞

终于见到一个不写固定人数的答案了
hua 好棒!
2021_YoungFamily_org

还可以这样输入:

ages = [int(input()) for i in range(5)]