- 3

Ticket prices (24.2)

🥺 please help me to solve this.

9th Jun 2022, 5:31 AM
Yashwanth Kiran
9 Réponses
+ 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 ...
9th Jun 2022, 3:19 PM
Lothar
Lothar - avatar
+ 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!
9th Jun 2022, 7:46 AM
Ausgrindtube
Ausgrindtube - avatar
+ 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
9th Jun 2022, 3:32 PM
Ausgrindtube
Ausgrindtube - avatar
+ 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)
9th Jun 2022, 3:17 PM
NEZ
NEZ - avatar
+ 1
Ausgrindtude your code is correct
9th Jun 2022, 4:02 PM
Yashwanth Kiran
+ 1
🙏 thanks for your help
9th Jun 2022, 4:02 PM
Yashwanth Kiran
+ 1
No problem, you're welcome. If you have a problem in the future, can you add the code like I did?
9th Jun 2022, 5:55 PM
Ausgrindtube
Ausgrindtube - avatar
0
total=0 passengers=0 while(passengers<=5): passengers+=1 age=int(input()) if age<3: continue else: total+=100 print(total)
9th Jun 2022, 9:19 AM
Yashwanth Kiran
0
is it correct
9th Jun 2022, 9:20 AM
Yashwanth Kiran