+ 3
[solved] is it possible to remove digit from the sentence ??
string = " i am python23 and the98 great0" all_words = string.split() # a = string.replace("2","") # print(a) for word in all_words: for char in word: if char.isdigit(): a = string.replace(f"{char}"," ") print(a) this code is not working !!! desired output : -" i am python and the great"
3 ответов
+ 3
Remove the "a=string" and add the following ,
string=string.replace(f"{char}","")
That " a= " stores only the string with last digit removed .
+ 1
Hey Hemant Kosrekar yes it's true
Simply go through each letter of each word in given sentence then eachLetter. isdigit() will help you to figure out its digit or not then you can remove it.
Be careful remove doesn't work for strings
0
Thanks Abhay
I got the answer !