Sololearn kaleidoscope(easy) python | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 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)

30th Jun 2024, 12:56 AM
Halley Bellew
Halley Bellew - avatar
3 Respuestas
+ 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.
30th Jun 2024, 1:30 AM
Wong Hei Ming
Wong Hei Ming - avatar
+ 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.
30th Jun 2024, 5:23 AM
Bob_Li
Bob_Li - avatar
+ 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
30th Jun 2024, 6:16 AM
Halley Bellew
Halley Bellew - avatar