+ 2
Why is this answer not correct.please help me
QUESTION Ballpark Orders My ANSWER d = input(str()) l = d.split() #print(l) #print(l) n = 0 for v in l: if "Nachos" in v: n += 6 elif "Pizza" in v: n += 6 elif "Cheeseburger" in v: n += 10 elif "Water" in v: n += 4 elif "Coke" in v: n += 5 else: n += 5 print(n*1.07)
5 Answers
+ 3
They probably want you to have only two decimal places.
Try this line of output:
print(f'{n*1.07:.2f}')
+ 1
You have to show us your attempt, otherwise we have no way of knowing!
+ 1
thank you for your quick reply.I will try it!
0
i am sorry .
please see below this question
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
0
I'm working on the same problem, I don't understand what I'm doing wrong either. I tested the same test cases on pycharm and it works fine there, I even modified it to show subtotal and tax in addition to the total.
This is the code (only prints total for all four items):
#----Ballpark Order---------------------------------
menu = ["Nachos", "Pizza", "Cheeseburger", "Water", "Coke"]
order = input().split()
list(order)
subtotal = 0
for item in list(order):
if item == "Nachos":
subtotal += 6.00
if item == "Pizza":
subtotal += 6.00
if item == "Cheeseburger":
subtotal += 10.00
if item == "Water":
subtotal += 4.00
if item == "Coke":
subtotal += 5.00
else:
for item in order:
if item not in menu:
subtotal += 5.00
tax = subtotal * (7 / 100)
total = subtotal + tax
print(total)
#----------end code------------------------------
My error message on solo learn's compiler says:
File "/usercode/file0.py", line 12
if item == "Nachos":
^
SyntaxError: invalid character in identifier
There is an invalid character in the code. The code should read "if item in menu:" instead of "if item in order:'. Experience means making a lot of mistakes