0
Can anyone help in no numerical in python
x=input() d= {"1":"one", "2":"two", "3":"three","4":"four","5":"five","6":"six","7":"seven","8":"eight","9":"nine","10":"ten","0":"zero"} for i in d: x=x.replace(i,d[i]) print(x) ...this is my code but failing one test case....can anyone tell what is wrong in this code
4 odpowiedzi
+ 8
To avoid the trouble by detecting single digit numbers or two-digit numbers in this task, the input could be split. So 10 is really "ten" and not "onezero".
+ 6
I think what Jayakrishna🇮🇳 said is correct. In your for loop, 'i' is assigned only a single character each time, so it will never find "10". It will find "1" and change to "one" and then find the "0" and change it to "zero", so "10" -> "onezero".
+ 1
Similar to key : value for 0,you shloud take 1 also after 10 in dictionary i guess..