+ 4

Why this code doesn't perform correctly in code coach? Please help.

change_char = {'1':'one', '2':'two', '3':'three', '4':'four','5':'five', '6':'six','7':'seven', '8':'eight','9':'nine','0':'zero','10':'ten'} nums = ['1','2','3','4','5','6','7','8','9','0'] y = str(input()) for i in y: if i in nums: y = y.replace(i, change_char[i]) print(y)

9th Jan 2020, 3:31 AM
Avinash
Avinash - avatar
5 Réponses
+ 7
Avinash So you want solution :P ?
9th Jan 2020, 7:30 AM
Ozair Khan
Ozair Khan - avatar
+ 8
I think there is one test case with number 10 which your program doesn't take. It will take 1 and 0 separately and replace with one and zero but it wants ten. Hence the problem..
9th Jan 2020, 4:16 AM
Ozair Khan
Ozair Khan - avatar
+ 5
I already thought about that...
9th Jan 2020, 7:18 AM
Avinash
Avinash - avatar
+ 4
Hmm..
9th Jan 2020, 8:24 AM
Avinash
Avinash - avatar
+ 4
I've also stuck in another code coach...
9th Jan 2020, 8:25 AM
Avinash
Avinash - avatar