+ 1
Sololearn kaleidoscope(easy) python
I'm not sure what I'm doing wrong but would anyone be willing to help me with my code on the kaleidoscope python test? It keeps failing on only one of the tests and I'm not sure why as I can't see the input and output for that one. order = (input()) order =int(order)*5 if order <= 4.99: ordertax = 0 if order == 5: ordertax = order *0.07 ordertax = ordertax+order if order >= 10: orderdis = order * 0.10 orderdis = order - orderdis ordertax = orderdis *0.07 ordertax = ordertax+orderdis ordertotal= '{:,.2f}'.format(ordertax) print(ordertotal)
3 Respostas
+ 4
x = 10000.123
print('{:,.2f}'.format(x)) # 10,000.12
print(round(x, 2)) # 10000.12
The result must be an EXACT MATCH, otherwise it fails.
+ 2
I agree with Wong Hei Ming. Don't add unnecessary ',' in your float formatting.
you are also doing more conditional checking than necessary. It does not need to be that complicated.
+ 2
Thank you guys I tried the round(x,2) and it worked! I tried a bunch of different things because I just couldn't figure out why it kept failing