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

24th Aug 2022, 10:20 AM
Bartels
Bartels - avatar
12 Respostas
+ 5
The if-statement needs to be inside of the while loop.
24th Aug 2022, 10:41 AM
Lisa
Lisa - avatar
+ 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.
24th Aug 2022, 10:27 AM
Lisa
Lisa - avatar
+ 2
Auto capitalization ? Or identation errors ? Save code in playground and share link here..
24th Aug 2022, 10:26 AM
Jayakrishna 🇼🇳
+ 2
Read the reply and then adjust your code. The if-statement needs to be indented so it is inside the loop
24th Aug 2022, 10:45 AM
Lisa
Lisa - avatar
+ 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
24th Aug 2022, 10:46 AM
Jayakrishna 🇼🇳
24th Aug 2022, 10:40 AM
Bartels
Bartels - avatar
+ 1
Bartels Read my code comments carefully, about your mistakes....
24th Aug 2022, 10:51 AM
Jayakrishna 🇼🇳
+ 1
Thanks again guys you have saved me thanks again â™„ïžâ™„ïžâ™„ïžâ™„ïžâ™„ïžđŸ€—đŸ€—đŸ€—
24th Aug 2022, 10:58 AM
Bartels
Bartels - avatar
0
Have post the code
24th Aug 2022, 10:39 AM
Bartels
Bartels - avatar
0
Write it Let me see pls
24th Aug 2022, 10:44 AM
Bartels
Bartels - avatar
0
I did it my error is saying age = int(input())
24th Aug 2022, 10:49 AM
Bartels
Bartels - avatar
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)
26th Aug 2022, 5:47 AM
Shardul Vinay Khanang