0
I made a mistake in the code: I can not find where. help me please =)
Task - Ballpark Orders: https://www.sololearn.com/coach/15?ref=app My code: https://code.sololearn.com/cLW3M85EE8vf/?ref=app 2/5 of the tests are successful, the rest of the tests fail and they are hidden. Anyone have any ideas where I made a mistake?
8 ответов
+ 1
I think there may be a rounding error here. My advice: change
tax = subtotal * 1.07
to
tax = subtotal * 107/100.
This should stop the rounding error.
+ 2
You haven't included what to do if i is "NACHOS". You need an extra elif i == "NACHOS":
+ 1
Yes, it worked! Thanks!
Right now I was thinking about trying to round out the output, but using my curve method:
...
total_with_tax = ("%6.2f" % (subtotal * 1.07))
...
And thank You for Your advice on rounding!
+ 1
The common way is to use round().
print(round(subtotal*1.07, 2)) should work too I think. The 2 means to 2 decimal places in case you weren't sure.
+ 1
To better remember, I also checked "round()" - this method also works. Thanks
0
Russ, thank you!
I added "elif i = = "nachos": ..."
It should have worked, but it didn't... The same result is 2/3
It is logical that the problem is in the 'NACHOS', but what is it?...
0
Did you try that too?
0
Yes, both options work. But I think yours is more appropriate.
I don't even know how this thing I wrote works, just copied it from the Internet. *Facepalm*
Your option is simpler and works.