+ 2

How to get continue in proper loop

My code is total mess I can't pass this practice help

18th Feb 2022, 5:17 AM
Deen Hifaz
Deen Hifaz - avatar
4 Antworten
+ 1
Deen Hifaz You don't need to print age. You are not incrementing value of passenger so while loop will keep running Your code is not proper indent. If there is continue then no need of else total = 0 passenger = 0 while passenger < 5: age = int(input()) if age < 3: continue total += 100 passenger += 1 print (total)
18th Feb 2022, 6:57 AM
A͢J
A͢J - avatar
+ 2
Where is your code?
18th Feb 2022, 5:39 AM
A͢J
A͢J - avatar
+ 1
total = 0 #answer goes here passenger = 0 while passenger<5: age = input() print(age) if int(age)<3: continue else: total+=100 print(total) Don't no what's wrong
18th Feb 2022, 5:40 AM
Deen Hifaz
Deen Hifaz - avatar
+ 1
"""I'm not shure what you want to solve, but here is an example: Input age of 5 passanger. If age >= 3 add 100 to to the total price. The price is 0 if passager < 3 years old. Do the input like this: line1: 3 # Number of passengers (3) line2: 10 # age at passager 1 line3: 1 # age at passager 2 line4: 36 # age at passager 3 The above input will give the total price 100 + 0 + 100 = 200. (In SoloLearns app: make all input at once.) """ total = 0 passenger = 0 num_of_passengers = int(input()) while passenger < num_of_passengers: passenger += 1 age = int(input()) print(f"Passenger {passenger}: age = {age} => price: {100 if age >= 3 else 0}") if age < 3: continue else: total += 100 print(f"Total price: {total}") https://code.sololearn.com/c0s2tL5xP0CX/?ref=app
18th Feb 2022, 6:35 AM
Per Bratthammar
Per Bratthammar - avatar