Title: Removing numbers from a given string
Tags: string;list;function;numeric;word
Question: I am trying to get rid of any numbers in a string.
However, when I run my program the number is removed, but other parts of the string are removed as well.
string = 'My name is Anish, &amp; I am 22 years old! The wall is blue, and the floor is orange. The weather is great, but it is raining?'
def num_remover(words):
t = words.split()
d = [e for e in t if e.isalpha()]
a = " ".join(d)
return a
print(bluh_remover(string))
output:
My name is I am 22 years The wall is and the floor is The weather is but it is
Comment: Welcome to SO! Minor nitpick, but `bluh_remover` isn't in the code--you probably meant `num_remover`. Can you show your actual output to contrast with your expected output? Thanks.

Comment: It would be nice to add information in which programming language it is, add it also to labels.


Here is another answer: It is missing because you have split the string, therefore, the word Anish will come as 'Anish,' which is not string because of special character.
string = 'My name is Anish, &amp; I am 22 years old! The wall is blue, and the floor is orange. The weather is great, but it is raining?'
def num_remover(words):
new = ''
temp = ''
for i in words:
if i.isdigit():
new = new + temp
temp = ''
else:
temp = temp + i
return new + temp
print(num_remover(string))
Output:
My name is Anish, &amp; I am  years old! The wall is blue, and the floor is orange. The weather is great, but it is raining?

Here is another answer: NEVERMIND: I figured it out.
Apart from calling out the wrong function haha. I was able to think simply and just replace the number with nothing.

Here is another answer: For any string longer than 10 words, a simple Replace loop would be faster. In VBA, for example:
Dim StrTxt As String, i As Long
StrTxt = "My name is Anish, &amp; I am 22 years old! The wall is blue, and the floor is orange. The weather is great, but it is raining?"
For i = 0 To 9
StrTxt = Replace(StrTxt, i, "")
MsgBox StrTxt

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 3, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:05/29/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<string><list><function><numeric><word>', 'Title': 'Removing numbers from a given string', 'ViewCount': 14, 'id': 62089585, 'user_AboutMe': None, 'user_AccountId': 18713060.0, 'user_DisplayName': 'Anish Patel', 'user_Reputation': 1.0, 'user_Views': 0.0, 'user_id': 13642746.0}}