New course! Every coder should learn Generative AI!
Try a free lesson+ 1
anyone help me with this code problem
you are making a ticket System the price of a singelt ticket is $100 dollar. for the ticcket under the of 3. the ticket is free. program need to take the age of 5 passenger as an input and output the total price for the ticket sample input 18 24 2 5 42 sample output 400 total = 0 x = 0 while x < 5: age = int(input()) if age >3: total += 100 x+1 print(total) This is my code the problem is it didn't calculate the input..
11 Answers
+ 5
Where is your attempt? If you post your code we can help you.
+ 4
Simanye There is no need for the else statement since it does nothing to change the variable.
Also, posting ready made codes and answers is against forum guidelines. That's why I asked for their attempt 😉
+ 3
Which course? Lesson name? Which language?
Maybe you need to review the lessons.
The code posted by another user in this discussion is one possible solution using Python.
+ 2
pls Omel Oncepido post your code too cuz this place is nor for getting readymade solutions first try it yourself and than still you unable to make it well , than we will help you!
+ 1
total_price=0
for i in range(5):
age=int(input())
if age>3:
total_price=total_price+100
else:
total_price=total_price
print(total_price)
+ 1
i forget to indecate. it's firtime for posting here, pardon all
+ 1
Hi !
You have to indent the if code block.
+ 1
total = 0
x = 0
while x < 5:
age = int(input())
if age > 3:
total += 100
x += 1
print(total)
here you go bro
0
I'm totally confused calculate the input from user
0
ohhh, pardon for lack of my info. about the problem. this one is phytoon lang. program problem
0
I think your code is not producing the output you're expecting due to incorrect indentation. Your if statement and the 2 lines below are not within the while loop. You need to shift them right so that the total gets updated for each input. (or maybe it's just displaying weirdly on my phone 😁)