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

ballpark orders

food_cost = [] order = input('Order please: ').split() print(f'your order: {order}') for i in order: if 'Pizza' in i: food_cost.append(6.00) elif 'Nachos' in i: food_cost.append(6.00) elif 'Cheeseburger' in i: food_cost.append(10.00) elif 'Water' in i: food_cost.append(4.00) elif 'Coke' in i: food_cost.append(5.00) else: food_cost.append(5.00) food_cost = sum(food_cost) #efore_tax = str(food_cost) #print(f'before tax: {before_tax}') tax = food_cost / 100 * 7 int_tax = float(tax) print(f'tax is: {tax}') print(f'total cost: {food_cost + tax}' My code is printing out the correct output as displayed in the expected output but the test cases are not approving

21st Jun 2022, 5:52 PM
Zain Ahmed
23 Answers
+ 1
#Try this instead menu = {"Pizza": 6.0, "Nachos": 6.0, "Cheeseburger": 10.0, "Water": 4.0} orders = input().split() cost = 0.0 for order in orders: cost += menu.get(order, 5.0) print(round(cost * 1.07, 2))
29th Sep 2022, 7:27 AM
Eugene Teh
Eugene Teh - avatar
0
Test cases expect output only the result. Don't add, any extra or less character as compare to expected output.
21st Jun 2022, 5:58 PM
Jayakrishna 🇮🇳
0
Ok
21st Jun 2022, 5:58 PM
Zain Ahmed
0
I passed 1 - 4 test cases but the 5th test case is locked so I cannot really tell what the problem is
21st Jun 2022, 6:01 PM
Zain Ahmed
0
Use Tax = food_cost * 7/100 Not food_cost*100/7
21st Jun 2022, 6:14 PM
Jayakrishna 🇮🇳
0
I see
21st Jun 2022, 6:15 PM
Zain Ahmed
0
Can you post the task description along with update code, share code link..
21st Jun 2022, 6:19 PM
Jayakrishna 🇮🇳
0
Test case 5 is still not approved
21st Jun 2022, 6:19 PM
Zain Ahmed
0
Ok
21st Jun 2022, 6:19 PM
Zain Ahmed
21st Jun 2022, 6:21 PM
Zain Ahmed
0
Update this to exactly code that you using in challenge.. This code not pass any case..
21st Jun 2022, 6:24 PM
Jayakrishna 🇮🇳
0
Ok
21st Jun 2022, 6:25 PM
Zain Ahmed
0
Done
21st Jun 2022, 6:26 PM
Zain Ahmed
0
I think this will also not pass any.. Use only print(food_cost + tax) And try to take original input values by don't converting to lowercase...
21st Jun 2022, 6:28 PM
Jayakrishna 🇮🇳
0
Ok
21st Jun 2022, 6:29 PM
Zain Ahmed
0
Try now
21st Jun 2022, 6:31 PM
Zain Ahmed
0
Guess it works...What is the result in code coach?
21st Jun 2022, 6:34 PM
Jayakrishna 🇮🇳
0
Let me recheck
21st Jun 2022, 6:35 PM
Zain Ahmed
0
No test case 5 doe not work
21st Jun 2022, 6:37 PM
Zain Ahmed
0
Does*
21st Jun 2022, 6:37 PM
Zain Ahmed