Kaleidoscopes Challenge: SOLVED | Sololearn: Learn to code for FREE!


Kaleidoscopes Challenge: SOLVED

Hey folx, I'm trying to complete the Kaleidoscopes challenge. My code is giving the correct result, but because it's not rounding to two decimal places, I keep failing 3/5 tests. Can anyone help me figure out what's wrong? Challenge: https://www.sololearn.com/coach/44?ref=app My Solution: https://code.sololearn.com/cCq6UOU7k5Z4/?ref=app

2/27/2020 3:01:42 PM

Élysse Marcellin

5 Answers

New Answer


If the purchase is 7, the result from your code is 33.705000000000005. So you have to round according the task description (if there is one), or use standard formatting output like f'{YourNumber:.2f}' with f-string.


It should be like this: print(f'{total_cost * disc:.2f}') I recommend you to go through the complete python tutorial, i am sure that this is mentioned there.


Lothar the task says the result should be rounded "to 2 decimal places", but I realised I don't know how to do that. I tried using the "round" function, but then I wasnt sure how to get the two decimal places using that either. How would I use the f-string function in this case?


Thanks Lothar! That formatting tip did the trick. I'm still trying to go through the python course, but I had to go back over some content to better understand it before I moved on again. But thanks for the help!