Ballpark Orders | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Ballpark Orders

Hi, I know there is better and more efficient ways to answer this (dictionary) but I was just wondering why the code bellow does not pass Test Case #2 (Passes everother test): order = input().split(" ") amount = 0 for food in order: if food == "Nachos" or food "Pizza": amount += 6 elif food == "Cheeseburguer": amount += 10 elif food == "Water": amount += 4 else: amount += 5 print(amount + (amount * 7) / 100) For the test "Cheeseburguer Cheeseburguer Coke Water" my output is 20.33 I just want to understand the mistake in the logic

12th Jun 2023, 9:35 PM
Davide Araujo
Davide Araujo - avatar
4 Answers
+ 5
Davide Araujo Solved it. Took me a while because im blind but its pretty hard to see. Im guessing english is not your frist language and your logic is 100% correct good job. the problem is you spelt Cheeseburger wrong. So in your elif just make that quick fix and you should be fine. ❌ Cheeseburguer ✅ Cheeseburger
12th Jun 2023, 9:58 PM
Junior
Junior - avatar
+ 2
order = input().split(" ") amount = 0 for food in order: if food == "Nachos" or food == "Pizza": # Added the equality comparison operator (==) amount += 6 elif food == "Cheeseburguer": amount += 10 elif food == "Water": amount += 4 else: amount += 5 print(amount + (amount * 7) / 100) The mistake in the logic of your code lies in the conditional statement for checking if food is equal to "Nachos" or "Pizza". You missed the equality comparison operator (==) after food == "Nachos" in the if statement.
14th Jun 2023, 10:53 AM
Vaibhav
Vaibhav - avatar
+ 1
Lol, ty so much. A real headscracher for some time now x) Thank you for taking the time
12th Jun 2023, 10:55 PM
Davide Araujo
Davide Araujo - avatar
+ 1
12th Jun 2023, 11:10 PM
Junior
Junior - avatar