+ 1

Ballpark Order Python

Hello, My code is accepted for the 2 first scenario but not the 3 others, which of course I cannot check. If someone can help me out to find out what is wrong. total = 0 tax = 1.07 list1 = {"Nachos": 6, "Pizza" : 6, "Cheeseburger" : 10, "Water" : 4, "Coke" : 5} order = input().split(" ") for i in order: total += list1.get(i, 5) print(total * tax)

1st Jul 2022, 12:57 PM
Aurélien Robert
Aurélien Robert - avatar
5 ответов
+ 3
Can you send the description of the code challenge here? It could be related to the problem's instructions. Also, did you try rounding it to 2 decimals (if stated in instruction)?
1st Jul 2022, 1:15 PM
noteve
noteve - avatar
+ 2
Thank you NotEve, I just needed to round, print(round(total * tax, 2) Thanks again :) didn't think of it
1st Jul 2022, 1:22 PM
Aurélien Robert
Aurélien Robert - avatar
+ 1
You and three friends go to a baseball game and you offer to go to the concession stand for everyone. They each order one thing, and you do as well. Nachos and Pizza both cost $6.00. A Cheeseburger meal costs $10. Water is $4.00 and Coke is $5.00. Tax is 7%. Task Determine the total cost of ordering four items from the concession stand. If one of your friend’s orders something that isn't on the menu, you will order a Coke for them instead. Input Format You are given a string of the four items that you've been asked to order that are separated by spaces. Output Format You will output a number of the total cost of the food and drinks. Sample Input 'Pizza Cheeseburger Water Popcorn' Sample Output 26.75
1st Jul 2022, 1:17 PM
Aurélien Robert
Aurélien Robert - avatar
+ 1
Aurélien Robert I provided an another hint that could solve the problem but you have already solved it, and that's good to know. Congrats and you're welcome.
1st Jul 2022, 1:27 PM
noteve
noteve - avatar
0
Aurélien Robert Looks like there is nothing wrong with your code, but the problem could be on the calculation of final price including tax. TRY: Instead of multiplying the 1.07 (price and tax) to the total price, calculate first the tax (0.07) before adding it to total price. 🔸 tax = 1.07 🔸 print(total * tax) 🔹 tax = 0.07 🔹 print(total + (total * tax))
1st Jul 2022, 1:25 PM
noteve
noteve - avatar