+ 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
9 Respuestas
+ 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!
+ 3
Worship And Praise ,
please post your code here, so that we can see where the issue is.
thank you!
+ 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)
+ 2
You try?
+ 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!
+ 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
+ 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)
+ 1
And it works
0
Thanks