- 3
Ticket prices (24.2)
🥺 please help me to solve this.
9 Answers
+ 3
Yashwanth Kiran ,
there are 3 issues in the code:
-> the conditional in the while loop header should be ... < 5 ...
-> the lines after: if...: and after: else: have incorrect indentation. should be like:
if...:
# do this ...
else:
# do that ...
+ 2
https://www.sololearn.com/Discuss/3043728/?ref=app
Posting multiple times isn't necessary.
We just need to see your code. Can you please copy it into the code playground and attach it here?
Thanks for including the language in the tags!
+ 2
These guys beat me to it! (I've not done any python yet...)
Here's my code:
passengers = 0
total = 0
while passengers < 5:
age = int(input())
if age <= 3:
passengers += 1
//print(str(passengers) + " age < 3")
else:
total += 100
passengers += 1
//print(str(passengers) + " age > 3")
print(total)
As the others said, indentation and the while condition were incorrect.
https://code.sololearn.com/cu564jCO2OLt/?ref=app
+ 1
'''
Yashwanth Kiran
No, the code had some indentation errors [line 7 and 9] and you wrote 'passengers<=5' it should be 'passengers<5'
Here's the corrected code:
'''
total=0
passengers=0
while(passengers<5):
passengers+=1
age=int(input())
if age<3:
continue
else:
total+=100
print(total)
+ 1
Ausgrindtude your code is correct
+ 1
🙏 thanks for your help
+ 1
No problem, you're welcome.
If you have a problem in the future, can you add the code like I did?
0
total=0
passengers=0
while(passengers<=5):
passengers+=1
age=int(input())
if age<3:
continue
else:
total+=100
print(total)
0
is it correct