0
Help me solve this ticket system problem in Python.
Total = 0 Passenger = 0 While passenger<=5: Age = int(input()) If age>3: Total+=100 Passenger+=1 If (age<3): Continue Print(total) This is a ticket system, in which a ticket is $100 . Children under 3 years have free ticket. Now write a program that 5 passengers entered their age. These 5 passengers 3 children are included. Then it will output 200 as 2 adults are involved. Pls help me with this. Mine above is not working
12 ответов
+ 5
The if-statement needs to be inside of the while loop.
+ 3
Please check your spellings, it is "while", not "While" for example.
also check the indentations and consider the case when someone is not > 3 or < 3 but exactly 3 years old.
+ 2
Auto capitalization ? Or identation errors ?
Save code in playground and share link here..
+ 2
Read the reply and then adjust your code.
The if-statement needs to be indented so it is inside the loop
+ 2
#since you gave us your try , this is total corrected code:
total = 0
passenger = 0
while passenger<5:
passenger+=1
age = int(input())
if age>=3: # sholud add same space before if as per above statement age= int( input(()), to belong to loop.
total+= 100
print(total)
#Under 3 means should not consider below 3. But include 3. Use age >= 3 , not age> 3
+ 1
Bartels Read my code comments carefully, about your mistakes....
+ 1
Thanks again guys you have saved me thanks again ♥️♥️♥️♥️♥️🤗🤗🤗
0
Have post the code
0
Write it Let me see pls
0
I did it my error is saying age = int(input())
0
You have made it a bit complicated and all the functions used are not in CAPS rather in small letters
Please refer to the following program :-
total=0
x=0 #x is the no.of passenger
while x<5:
age=int(input())
if age>3:
total+=100
x+=1
print(total)