+ 2
How to get continue in proper loop
My code is total mess I can't pass this practice help
4 Respuestas
+ 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)
+ 2
Where is your code?
+ 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
+ 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