0

Tickets and price (from break&continue lesson) (Python)

(Not a pro subscription task) 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 ---------------------------------------------------------------------------------------------- I'm literally sitting on it for an hour. My last version for this case is total = 0 price = 100 age = int(input()) final_total = total + price i = 5 while i > 0: i -= 1 if age >= 4: print(total + price) elif age <= 3: continue print (final_total) could someone help me to correct it? (hope I added all needed info someone to help...)

1st Jan 2025, 4:33 PM
Александра Бондаренко
Александра Бондаренко - avatar
6 odpowiedzi
+ 4
Give a complete task description.
1st Jan 2025, 4:51 PM
Lisa
Lisa - avatar
+ 4
Александра Бондаренко , > since we have a real bunch of `python` tutorials, please also specify the *exact* name of the tutorial. just naming `python` does not really help. > it would also be helpful to know, whether this exercise requires a `pro` subscription.
1st Jan 2025, 4:57 PM
Lothar
Lothar - avatar
+ 4
age = int(input()) goes INSIDE the loop. i MUST be updated before you continue INSIDE the loop. "under the age of 3" means age < 3. check the indentation of your code. check the spelling of "continue". output the total price only once – after the loop.
1st Jan 2025, 6:58 PM
Lisa
Lisa - avatar
+ 2
you need to take the ages of 5 persons as input. you currently only take input once. you need to get input inside the loop
1st Jan 2025, 5:40 PM
Lisa
Lisa - avatar
+ 1
My last version is total = 0 price = 100 age = int(input()) i = 5 while i > 0 and while age >= 4: print(total += price) if age <= 3: continiue i -= 1 But as far as there can't be two while in one loop. Idk
1st Jan 2025, 5:58 PM
Александра Бондаренко
Александра Бондаренко - avatar
0
I can't understand, could u please correct my code?
1st Jan 2025, 5:55 PM
Александра Бондаренко
Александра Бондаренко - avatar