[solved] Ballpark orders | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

[solved] Ballpark orders

Hi everybody, I'm trying to solve the ball park orders code coach problem. This is my code. It seems it doesn't work... What's wrong with it? orders = input() orders_list = orders.split() sum = 0 for i in orders_list: if i == "Nachos": sum = sum + 6 elif i == "Pizza": sum = sum + 6 elif i == "Cheeseburger": sum = sum + 10 elif i == "Water": sum = sum + 4 elif i == "Coke": sum = sum + 5 else: sum = sum + 5 print(sum*1.07)

17th Jan 2021, 5:15 PM
Cactus
Cactus - avatar
6 Answers
+ 8
I can't see the challenge, but I suspect the problem may have something to do with rounding. sum * 1.07 may lead to multiple decimal places
17th Jan 2021, 8:07 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 4
What error do you get?
17th Jan 2021, 5:41 PM
Sonic
Sonic - avatar
+ 3
Thank you Rik! I solved the problem with print(round(sum*1.07,2))
17th Jan 2021, 8:20 PM
Cactus
Cactus - avatar
+ 2
For me the solution Is the round function to 2 decimals. Thank you for the kind suggest, Cactus
10th Jun 2022, 10:57 PM
Federico Bassi
Federico Bassi - avatar
+ 1
I don't get any error. But the code doesn't pass the test cases from 3 to 5, but they are hidden... So it's not easy for me to understand where is the problem... If I try it with a python compiler it always works fine...
17th Jan 2021, 6:39 PM
Cactus
Cactus - avatar
+ 1
Cactus Well done!
17th Jan 2021, 9:49 PM
Rik Wittkopp
Rik Wittkopp - avatar