+ 1

Why is it not working?

x= input() d={"0":"zero","1":"one","2":"two","3":"three","4":"four","5":"five","6":"six","7":"seven","8":"eight","9":"nine"} for i in x: if i.isdigit(): c=d[i] x.replace(i,c) print (x)

23rd Apr 2020, 3:07 AM
Gaurav
Gaurav - avatar
3 Respuestas
+ 3
The .replace() doesn't change the original variable. So you can assign it to a new variable or same: https://code.sololearn.com/ccGd0Kh81e5X/?ref=app
23rd Apr 2020, 4:21 AM
Tricker
+ 4
23rd Apr 2020, 5:10 AM
💡Arno Gevorgyan 🐍
💡Arno Gevorgyan 🐍 - avatar
+ 1
Yes I got it . This should be like this X=x.replace(str(i),d[i])
2nd May 2020, 9:22 AM
Gaurav
Gaurav - avatar