Your boss decided to save money by purchasing some cut-rate optical character recognition software for scanning in the text of old novels to your database. At first it seems to capture words okay, but you quickly notice that it throws in a lot of numbers at random places in the text. For example:

```python
string_clean('! !') == '! !'
string_clean('123456789') == ''
string_clean('This looks5 grea8t!') == 'This looks great!'

```

Your harried co-workers are looking to you for a solution to take this garbled text and remove all of the numbers. Your program will take in a string and clean out all numeric characters, and return a string with spacing and special characters `~#$%^&!@*():;"'.,?` all intact.

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def string_clean(s):
	

Solutions:
def string_clean(s):
	return ''.join((x for x in s if not x.isdigit()))


import re

def string_clean(s):
	return re.sub('\\d', '', s)


def string_clean(s):
	return ''.join((c for c in s if not c.isdigit()))


string_clean = lambda s: __import__('re').sub('\\d', '', s)


def string_clean(s):
	import re
	return ''.join(re.findall('\\D', s))


def string_clean(s):
	return s.translate(s.maketrans(' ', ' ', '1234567890'))


def string_clean(s):
	return ''.join((ch for ch in s if ch not in '0123456789'))


from string import digits
trans = str.maketrans('', '', digits)

def string_clean(s):
	return s.translate(trans)
from functools import partial
from re import compile
string_clean = partial(compile('\\d+').sub, '')


import re
string_clean = lambda s: re.sub('[0-9]', '', s)


def string_clean(s):
	return ''.join([item for item in s if not item.isdigit()])


string_clean = lambda s: ''.join((e for e in s if not e.isdigit()))


def string_clean(s):
	return __import__('re').sub('\\d', '', s)


def string_clean(s):
	return ''.join((c for c in s if c not in '1234567890'))


import re

def string_clean(s):
	return re.sub('[0-9]', '', s)


def string_clean(s):
	return ''.join([i for i in s if not i.isnumeric()])


def string_clean(s):
	return s.replace('1', '').replace('2', '').replace('3', '').replace('4', '').replace('5', '').replace('6', '').replace('7', '').replace('8', '').replace('9', '').replace('0', '')


from re import sub

def string_clean(s: str) -> str:
	return sub('\\d', '', s)


def string_clean(s):
	return ''.join(__import__('itertools').filterfalse(str.isdigit, s))


def string_clean(s):
	return s.translate({ord(x): None for x in '0123456789'})


def string_clean(s):
	n = ''
	for i in s:
		if i not in '0123456789':
			n += i
	return n


def string_clean(s):
	nums = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
	return ''.join([_ for _ in s if _ not in nums])


from string import digits

def string_clean(s):
	foo = str.maketrans('', '', digits)
	bar = s.translate(foo)
	return bar


def string_clean(s):
	a = ''
	for el in s:
		if el not in '1234567890':
			a += el
	return a


def string_clean(s):
	res = ''
	for i in range(len(s)):
		if not s[i].isdigit():
			res += s[i]
	return res


def string_clean(s):
	x = []
	for i in range(len(s)):
		if s[i] in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']:
			x = x
		else:
			x.append(s[i])
	return ''.join(map(str, x))


def string_clean(s):
	num = '0123456789'
	for i in s:
		if i in num:
			s = s.replace(i, '')
	return s


def string_clean(s):
	no_digits = []
	for i in s:
		if not i.isdigit():
			no_digits.append(i)
	result = ''.join(no_digits)
	return result


def string_clean(s):
	deprecated = '0123456789'
	return ''.join([s_ for s_ in s if s_ not in deprecated])


def string_clean(s):
	new = ''
	for char in s:
		if char.isdigit():
			new += ''
		else:
			new += char
	return new


def string_clean(s):
	for c in '1234567890':
		s = s.replace(c, '')
	return s


def string_clean(s):
	return ''.join(list((el if not el.isdigit() else '' for el in s)))


def string_clean(s):
	ls = []
	final = []
	for i in s:
		if '0' <= i <= '9':
			ls.append(i)
		else:
			final.append(i)
	return ''.join(final)


def string_clean(s):
	return ''.join(('' if ch in '0123456789' else ch for ch in list(s)))


def string_clean(s):
	numset = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
	for i in s:
		if i in numset:
			s = s.replace(i, '')
	return s


import re
string_clean = lambda string: re.sub('\\d', '', string)


def string_clean(s):
	return ''.join([i for i in s if i.isdigit() != True])


def string_clean(s):
	numbers = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
	new_string_arr = []
	for char in s:
		if char not in numbers:
			new_string_arr.append(char)
	return ''.join(new_string_arr)


import re

def string_clean(s):
	s = s.translate(str.maketrans('0123456789', '0' * 10))
	return s.replace('0', '')


def string_clean(s):
	phrase = ''
	for i in range(len(s)):
		if s[i].isnumeric() != True:
			phrase += s[i]
	return phrase


def string_clean(s):
	toremove = '1234567890'
	for i in s:
		if i in toremove:
			s = s.replace(i, '')
	return s


def string_clean(s):
	return s.translate(str.maketrans({x: '' for x in '1234567890'}))


def string_clean(s):
	return ''.join((x for x in s if x.isdigit() == False))


def string_clean(s):
	return ''.join([s[i] for i in range(len(s)) if s[i].isnumeric() == False])


def string_clean(s):
	return s.translate(str.maketrans('1234567890', '0000000000')).replace('0', '')


def string_clean(s):
	return ''.join(['' if i in '0123456789' else i for i in s])


def string_clean(s):
	return ''.join([s[x] for x in range(len(s)) if not s[x].isnumeric()])


import string

def string_clean(s):
	for n in s:
		if n in string.digits:
			s = s.replace(n, '')
	return s


def string_clean(s):
	word = ''
	digits = '1234567890'
	for element in s:
		if element not in digits:
			word += element
	return word


def string_clean(s):
	c = ''
	for i in s:
		if i not in '0123456789':
			c = c + i
	return c


def string_clean(s):
	junk = [str(i) for i in range(10)]
	new_s = ''
	for i in s:
		if i not in junk:
			new_s += i
	return new_s


def string_clean(s):
	output = ''
	for x in s:
		print(x.isdigit())
		if x.isdigit():
			pass
		else:
			output += x
	return output


def string_clean(s):
	a = ''
	for c in s:
		if not c.isdigit():
			a += c
	return a


def string_clean(s):
	x = ''
	for i in s:
		if i >= '0' and i <= '9':
			continue
		x += i
	return x


def string_clean(s):
	n = '1234567890'
	for x in n:
		if x in s:
			s = s.replace(x, '')
	return s


def string_clean(s):
	return ''.join(list([x for x in s if x not in '1234567890']))


import string

def string_clean(s):
	out = ''
	for element in s:
		if not element.isnumeric():
			out += element
	return out


def string_clean(s):
	st = ''
	for c in s:
		if not c.isdigit():
			st += c
	return st


def string_clean(s):
	liste = list(s)
	el = []
	for elem in liste:
		if elem in '1234567890':
			pass
		else:
			el.append(elem)
	return ''.join(el)


def string_clean(s):
	return ''.join(['' if char.isdigit() else char for char in s])


def string_clean(s):
	ans = ''
	for i in s:
		if not i.isdigit():
			ans += i
	return ans


def string_clean(s):
	lsValue = ''
	for i in range(len(s)):
		if not s[i].isnumeric():
			lsValue += s[i]
	return lsValue


def string_clean(s):
	return ''.join((letter for letter in s if not letter.isnumeric()))


def string_clean(s):
	res = ''
	for i in s:
		if i.isdigit():
			continue
		else:
			res += i
	return res


def string_clean(s):
	y = ''
	for i in s:
		if i.isnumeric():
			continue
		else:
			y += i
	return y


def string_clean(s):
	remove_characters = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
	for character in remove_characters:
		s = s.replace(character, '')
	return s


def string_clean(s):
	new = ''
	for item in s:
		if item.isnumeric():
			pass
		else:
			new += item
	return new


import string
digits = string.digits

def string_clean(s):
	emptystring = ''
	for eachletter in s:
		if eachletter in digits:
			continue
		else:
			emptystring = emptystring + eachletter
	return emptystring


def string_clean(s):
	string = ''
	for char in s:
		if char not in '0123456789':
			string += char
	return string


def string_clean(s):
	ans = ''
	s = list(s)
	digits = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
	for i in s:
		if i in digits:
			continue
		ans = ans + i
	return ans


from string import digits

def string_clean(s):
	for char in digits:
		s = s.replace(char, '')
	return s


def string_clean(s):
	n = ''
	for i in range(0, len(s)):
		if s[i].isdigit():
			continue
		else:
			n = n + s[i]
	return n


def string_clean(s):
	wordclean = list(s)
	fini = []
	for i in wordclean:
		if i.isnumeric():
			a = 1
		else:
			fini.append(i)
	return ''.join(fini)


def string_clean(s):
	return s.translate(s.maketrans({'0': '', '1': '', '2': '', '3': '', '4': '', '5': '', '6': '', '7': '', '8': '', '9': ''}))


def string_clean(s):
	temp = ''
	numbers = '1234567890'
	for i in s:
		if i in numbers:
			continue
		else:
			temp += i
	return temp


import re

def string_clean(s):
	delNum = re.compile('[^0123456789]')
	return ''.join(delNum.findall(s))


def string_clean(s):
	result = ''
	for elem in s:
		if elem not in ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'):
			result += elem
	return result


def string_clean(s):
	num = '0123456789'
	fresh = []
	for i in s:
		if i not in num:
			fresh.append(i)
	return ''.join(fresh)


import re

def string_clean(s):
	o = []
	nonolist = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
	for x in list(s):
		if x not in nonolist:
			o.append(x)
	return ''.join(o)


def string_clean(s):
	new_s = ''
	for letters in s:
		if not 48 <= ord(letters) <= 57:
			new_s += letters
	return new_s


def string_clean(s):
	res = ''
	for c in s:
		if c not in '0123456789':
			res += c
	return res


def string_clean(s):
	for el in '0123456789':
		s = s.replace(el, '')
	return s


def string_clean(s):
	import re
	matches = re.finditer('[a-zA-Z~#\\$%^&!@*():;"\'\\.,?\\s]', s)
	return ''.join([match.group() for match in matches])


def string_clean(s):
	new = ''
	for char in s:
		if char in '1234567890':
			new += ''
		else:
			new += char
	return new