+ 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)
6 Antworten
+ 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
+ 4
What error do you get?
+ 3
Thank you Rik! I solved the problem with print(round(sum*1.07,2))
+ 2
For me the solution Is the round function to 2 decimals. Thank you for the kind suggest, Cactus
+ 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...
+ 1
Cactus Well done!