+ 1

I was struggling to solve this code question for days now. I need a help

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

17th Feb 2022, 4:54 PM
Hittloson
Hittloson - avatar
9 Answers
+ 8
Worship And Praise , please allow me some comments. the code you presented has some very basic issues like typos with upper case instead of lower case, missing or incorrect indentations. since you have not really started a python tutorial in sololearn, it is recommended to do so. you can learn there and practice, and you will grow in experience with each exercise you are doing. all other ways will lead to frustration. the learning path will take some time, so please be patient. a good start is the tutorial " python for beginners". happy coding and good success!
18th Feb 2022, 10:46 AM
Lothar
Lothar - avatar
+ 3
Worship And Praise , please post your code here, so that we can see where the issue is. thank you!
17th Feb 2022, 5:47 PM
Lothar
Lothar - avatar
+ 3
#Worship And Praise identation matters in python.. Always share link by saving code. It helps to find actual mistake. You are code is right but not idented properly..(edit : hoping typos are autocapitalized) # I just idented code properly. total =0 passenger =0 while(passenger <5): passenger +=1 age =int(input()) if(age <3): continue else: total +=100 print(total)
17th Feb 2022, 7:41 PM
Jayakrishna 🇼🇳
+ 2
You try?
17th Feb 2022, 5:44 PM
NEZ
NEZ - avatar
+ 2
Worship And Praise What I would use to solve this: a list to store each age a variable to store the total price a loop and an if statement to calculate the total price depending on the age Happy coding!
17th Feb 2022, 6:20 PM
Denise Roßberg
Denise Roßberg - avatar
+ 2
This is my solution Total =0 passenger =0 While(passenger <5): passenger +=1 age =int(input()) if(age <3): continue else: total +=100 print(total) And they say 'continue' is not placed well in the while loop I need your help
17th Feb 2022, 7:21 PM
Hittloson
Hittloson - avatar
+ 1
So I did it like this: total=0 x=0 while x<5: age=int(input()) if age>3: total+=100 x+=1 print(total)
19th Feb 2022, 3:30 PM
Bubble Tea
Bubble Tea - avatar
+ 1
And it works
19th Feb 2022, 3:30 PM
Bubble Tea
Bubble Tea - avatar
0
Thanks
19th Feb 2022, 3:19 AM
Hittloson
Hittloson - avatar