+ 1

Ballpark order

I have approached this code coach from several different ways. They all pass except test 4. Does anyone have any thoughts or suggestions. 1 approach was list, for loops another was dictionary and for loops. Seems like I’m overthinking this

22nd Oct 2020, 6:01 PM
Eric Bemiss
Eric Bemiss - avatar
5 Antworten
+ 5
I'd use a dictionary to store all available options as the key and their price as the value. Then use a variable to store the total before tax. Loop over the 4 input items (split into a list). In the loop check if the item is in the dictionary and if so add its value to the total. If not add the value of a coke to the total. Then calculate the tax for the total and add it to the total for output. Make sure the output format matches having 2 places after the decimal.
22nd Oct 2020, 6:20 PM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Thank you for the help, added the format, had the rest. Still fails test 4. Will continue to solve this challenge
23rd Oct 2020, 6:33 AM
Eric Bemiss
Eric Bemiss - avatar
+ 2
solved, took another look and found that i misspelled Nachos in the dictionary, thanks again
28th Oct 2020, 4:04 AM
Eric Bemiss
Eric Bemiss - avatar
+ 1
@ChaoticDawg thanks so much for your comment. You helped me figure out what I was missing (a check for items not on the menu)!
9th Dec 2020, 7:21 AM
Jacob Hargrave
Jacob Hargrave - avatar
0
can you please send me the problem statement for this
18th May 2021, 6:55 AM
Suraj Soni
Suraj Soni - avatar