I'm not sure what's wrong with the code. The test case it's failing is hidden: https://code.sololearn.com/c82wMVuVBhG9/?ref=app
1/19/2020 6:25:14 PM
I give you a hint:
Run your code with the input '10'
Create a dictionary mapping numbers 0-10 to its words form.
And the. use string replace method to change the value of index matching to that of dictionary
Thank you. I see the problem now.
I've now solved it. Thanks for the replies guys
I used a tuple to define the numbers as words. I iterated through it backwards to deal with 10 first.
I think the code is quite elegant now.
Learn Playing. Play Learning
Send us a message