+ 1
What is wrong with my code—help me with the “ticket price” problem
the question asks to calculate the total ticket price for the airline company, which you count $100 for whose age over 3 and 0 for those under 3. My code goes below. It always gives the eof error warning in line 4. What is wrong with it? total = 0 i=1 while i<5: age = input() if int(age) <3: continue total+=100 i+=1 print(total)
7 ответов
+ 4
Weitao Sun , it would be good if we could get the complete original task description from you. please also name the tutorial from which it comes.
+ 1
when input is less than 3 then your while loop is not counting i+=1 because of 'continue' so it asks 5 inputs which are >3 so answer is always 500 or input error. also I<5 causes loop run 4times only...
+ 1
Hi!
1. add another iteration to the loop. remember that you have 5 passengers.
2. the age of the passenger must be a number, not a string
3. replace "continue" with "total = total"
0
can you help me with the backlash one pls
0
print('I
'm learning!')
0
Lothar , the problem is the following:
You are making a ticketing system.
The price of a single ticket is $100.
For children under 3 years old, 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
0
ANASUYA WADHWA 7B please, ask your personal question by creating a new thread, since you are asking, few people will be able to see you and give help