+ 1

Working on Coding Challenges: "Ballpark Orders"

Hi! I working through the coding examples on here, finally. Python first. I worked through this one pretty easily. Here is my code, with comments describing my thought process. Can anyone help me figure out why I'm failing the secret cases? Also, is there any way to 'unlock' those cases so that I can examine the input? """ I try to keep thing simple, relying on basic functionality unless i see a direct reason to use something more complex """ order = input() # order as str # menu as an arr menu = ["Pizza", "Nachos", "Cheeseburger", "Water", "Coke"] #split order into items[] by space, couldve done in prior step as well item = order.split() # printed at the end with tax calculation cost = 0.00 # iterate through array of items for i in item: #deals with a request not on the menu if i not in menu: cost += 5 #add prices to cost for each item ordered elif i in menu: if i == "Pizza" or i == "Nachos": cost += 6 elif i == "Cheeseburger": cost += 10 elif i == "Water": cost += 4 elif i == "Coke" or i == None: cost += 5 print(cost*1.07) """ I have a love/hate relationship with the way this platform has secret cases for these coaching examples I cant think of why this would fail them """

9th May 2023, 7:05 AM
Deshon Morgan
Deshon Morgan - avatar
3 Respuestas
+ 6
Task requires is to round up result to 2 decimal point. So try print(round( cost*1.07, 2) ) test cases are hidden so it prevents users to hardcode solutions.
9th May 2023, 7:13 AM
Jayakrishna 🇮🇳
+ 3
Thank you! That makes sense.
9th May 2023, 7:14 AM
Deshon Morgan
Deshon Morgan - avatar