Write function RemoveExclamationMarks which removes all exclamation marks from a given string.

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def remove_exclamation_marks(s):
	

Solutions:
def remove_exclamation_marks(s):
	return s.replace('!', '')


remove_exclamation_marks = lambda s: s.replace('!', '')


def remove_exclamation_marks(s):
	x = s.replace('!', '')
	return x


def remove_exclamation_marks(s):
	return ''.join([x for x in s if x != '!'])


def remove_exclamation_marks(s):
	s = list(s)
	for x in s:
		if x == '!':
			s.remove(x)
	for x in s:
		if x == '!':
			s.remove(x)
	for x in s:
		if x == '!':
			s.remove(x)
	return ''.join(s)


def remove_exclamation_marks(s):
	new_s = ''
	for i in s:
		if i != '!':
			new_s += i
	return new_s


def remove_exclamation_marks(s: str) -> str:
	return s.replace('!', '')


import re

def remove_exclamation_marks(s):
	return re.sub('!', '', s)


def remove_exclamation_marks(s):
	y = list(s)
	for l in range(0, y.count('!')):
		y.remove('!')
	z = ''.join(y)
	return z


def remove_exclamation_marks(s):
	return ''.join(filter(lambda x: x.isalpha() or x == ' ' or x == ',', s))


def remove_exclamation_marks(s):
	return ''.join(list((l for l in s if l != '!')))


import string

def remove_exclamation_marks(s):
	d = {'!': None}
	t = str.maketrans(d)
	return s.translate(t)


def remove_exclamation_marks(s):
	temp = list(s)
	while '!' in temp:
		temp.remove('!')
	return ''.join(temp)


remove_exclamation_marks = lambda a: a.replace('!', '')


def remove_exclamation_marks(s):
	s1 = ''
	for i in s:
		if i != '!':
			s1 = s1 + i
	return s1


def remove_exclamation_marks(s):
	if '!' not in s:
		return s
	else:
		s1 = ''
		for caracter in s:
			if caracter != '!':
				s1 += caracter
		return s1


def remove_exclamation_marks(s):
	str = s.replace('!', '')
	return str
remove_exclamation_marks('Hello World!')
remove_exclamation_marks('Hello World!!!')
remove_exclamation_marks('Hi! Hello!')
remove_exclamation_marks('Oh, no!!!')


def remove_exclamation_marks(s):
	word = ''
	for let in s:
		if let != '!':
			word = word + let
	return word


remove_exclamation_marks = lambda s: ''.join((x for x in s if x != '!'))


def remove_exclamation_marks(s):
	res = [i for i in s if i != '!']
	return ''.join(res)


def remove_exclamation_marks(s):
	c = s.count('!')
	s = list(s)
	for i in range(c):
		s.remove('!')
	return ''.join(s)


def remove_exclamation_marks(s):
	lol = s.replace('!', '')
	return lol


def remove_exclamation_marks(s):
	result = ''
	for i in s:
		if i == '!':
			pass
		else:
			result += i
	return result


def remove_exclamation_marks(s):
	s = list(s)
	for i in range(len(s)):
		if '!' in s:
			s.remove('!')
	return ''.join(s)


def remove_exclamation_marks(s):
	for element in s:
		if element == '!':
			s = s.replace('!', '')
	return s


def remove_exclamation_marks(s):
	result = ''
	for y in s:
		if y != '!':
			result += y
	return result


def remove_exclamation_marks(s):
	a = ''
	for c in s:
		if c != '!':
			a += c
	return a


def remove_exclamation_marks(s):
	new_string = ''
	for char in s:
		if char == '!':
			pass
		else:
			new_string += char
	return new_string


def remove_exclamation_marks(s):
	return s.translate(str.maketrans({'!': ''}))


def remove_exclamation_marks(s):
	return s if not s else s.replace('!', '')


def remove_exclamation_marks(s):
	total = ''
	for i in s:
		if i != '!':
			total += i
	return total


def remove_exclamation_marks(s):
	r = list(s)
	for char in s:
		if char == '!':
			r.remove(char)
	string = ''
	for i in r:
		string += i
	return string


def remove_exclamation_marks(s):
	a = str()
	for i in s:
		if i != '!':
			a += i
	return a


def remove_exclamation_marks(s):
	a = ''
	for i in s:
		if i in '!':
			pass
		else:
			a += i
	return a


def remove_exclamation_marks(s):
	return ''.join([i for i in s if ord(i) != 33])


def remove_exclamation_marks(s):
	newS = ''
	for letters in s:
		if letters != '!':
			newS += letters
	return newS


def remove_exclamation_marks(s):
	no_mark = ''
	for word in s:
		if word != '!':
			no_mark += word
	return no_mark


def remove_exclamation_marks(s):
	S = ''
	for i in s:
		S = s.replace('!', '')
	return S


def remove_exclamation_marks(s):
	string = ''
	for x in s:
		if x != '!':
			string += x
	return string


def remove_exclamation_marks(s):
	sl = list(s)
	n = sl.count('!')
	i = 1
	while i <= n:
		sl.remove('!')
		i += 1
	return ''.join(sl)


def remove_exclamation_marks(s):
	newlist = s.replace('!', '')
	return newlist


import re

def remove_exclamation_marks(str):
	return ''.join(re.findall('\\w|\\s|[,]', str))


def remove_exclamation_marks(s):
	return s.replace('!', '')

def remove_exclamation_marks(s):
	return ''.join((char for char in s if char != '!'))

def remove_exclamation_marks(s):
	final_s = []
	for char in s:
		if char != '!':
			final_s.append(char)
	return ''.join(final_s)

def remove_exclamation_marks(s):
	print(('x', s, 'x'))
	i_compensation = 0
	s = list(s)
	for i in range(len(s)):
		print(('before', i))
		if s[i - i_compensation] == '!':
			s.pop(i - i_compensation)
			i_compensation += 1
	return ''.join(s)


def remove_exclamation_marks(s):
	new_string = ''
	for e in s:
		if e != '!':
			new_string += e
	return new_string


def remove_exclamation_marks(s):
	a = [s.strip('!') for s in s]
	return ''.join(a)


def remove_exclamation_marks(s):
	new_string = ''
	for i in s:
		if i != '!':
			new_string += i
	return new_string


def remove_exclamation_marks(s):
	for i in range(len(s)):
		count = s.count('!')
		s = s.replace('!', '', count)
	return s


def remove_exclamation_marks(s):
	list = [',', ' ', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', 'X', 'C', 'V', 'B', 'N', 'M']
	for i in s:
		if i in list:
			continue
		else:
			s = s.replace(i, '')
	return s


def remove_exclamation_marks(s):
	s = s.split(' ')
	no_marks = []
	for char in s:
		char = list(char)
		no_exc = []
		for x in char:
			if x != '!':
				no_exc.append(x)
		collect = ''.join(no_exc)
		no_marks.append(collect)
	return ' '.join(no_marks)


def remove_exclamation_marks(s):
	res = ''
	for i in s:
		if not i == '!':
			res = res + i
	return res


def remove_exclamation_marks(s):
	result = ''
	for i in s:
		if i != '!':
			result = result + i
	return result


def remove_exclamation_marks(s):
	m = list(s)
	x = []
	for i in m:
		if i != '!':
			x.append(i)
	v = ''.join(x)
	return v


def remove_exclamation_marks(s):
	return ''.join((i if i != '!' else '' for i in s))


def remove_exclamation_marks(s):
	return ''.join((ele for ele in s if ele != '!'))


def remove_exclamation_marks(s):
	res = ''
	for i in range(len(s)):
		if s[i] != '!':
			res += s[i]
	return res


def remove_exclamation_marks(s):
	return ''.join([i for i in list(str(s)) if i != '!'])


def remove_exclamation_marks(s):
	screw_the_exclaimation_mark = s.replace('!', '')
	return screw_the_exclaimation_mark


def remove_exclamation_marks(string):
	new = string.replace('!', '')
	return new


def remove_exclamation_marks(s):
	k = ''
	for i in s:
		if i != '!':
			k += i
	return k


def remove_exclamation_marks(s):
	ergebnis = ''
	for i in s:
		if i != '!':
			ergebnis += i
	return ergebnis


import unittest

def remove_exclamation_marks(s):
	return s.replace('!', '')

class TestRemoveExclamationMarks(unittest.TestCase):

	def test_only_one_exclamation_marks(self):
		s = 'Hello World!'
		actual = remove_exclamation_marks(s)
		self.assertEqual(actual, 'Hello World')

	def test_only_all_exclamation_marks(self):
		s = 'Hello World!'
		actual = remove_exclamation_marks(s)
		self.assertEqual(actual, 'Hello World')


def remove_exclamation_marks(s):
	bas = ''
	out = ''
	for i in s:
		if i == '!':
			bas += i
		else:
			out += i
	return out


def remove_exclamation_marks(s):
	char = ''
	for i in s:
		if i != '!':
			char += i
	return char


import re

def remove_exclamation_marks(s):
	return ''.join(re.findall('[a-z A-Z,]', s))


def remove_exclamation_marks(s):
	z = ''.join([l for l in s if l != '!'])
	return z


import re

def remove_exclamation_marks(my_list):
	return re.sub('!', '', my_list)


def remove_exclamation_marks(s):
	st = s.replace('!', '')
	return st


def remove_exclamation_marks(s):
	return ''.join(filter(lambda char: char != '!', list(s)))


def remove_exclamation_marks(s):
	out = ''
	for i in s:
		if i != '!':
			out += i
	return out


def remove_exclamation_marks(s):
	'!' in s == True
	return s.replace('!', '')


def remove_exclamation_marks(s):
	toprint = ''
	for char in s:
		if char != '!':
			toprint += char
	print(toprint)
	return toprint


def remove_exclamation_marks(s):
	d = ''
	for i in s:
		if i not in '!¡':
			d += i
	return d


def remove_exclamation_marks(s):
	a = s.strip('!')
	l = []
	for i in range(0, len(a)):
		s = a[i]
		l.append(s)
	while '!' in l:
		l.pop(l.index('!'))
	return ''.join(l)


def remove_exclamation_marks(n):
	return n.replace('!', '')


def remove_exclamation_marks(s):
	s1 = []
	for i in s:
		if i != '!':
			s1.append(i)
	return ''.join(s1)


def remove_exclamation_marks(s):
	n = ''
	for x in s:
		if x.isalpha() or x == ' ' or x == ',':
			n += x
	return n


def remove_exclamation_marks(s):
	lst = s.split('!')
	return ''.join(lst)


def remove_exclamation_marks(s):
	answer = ''
	for i in s:
		if i == '!':
			pass
		else:
			answer += i
	return answer


def remove_exclamation_marks(s):
	sp = s.split('!')
	new_string = ''.join(sp)
	return new_string


def remove_exclamation_marks(Str):
	Word = ''
	for s in Str:
		if not s == '!':
			Word += s
	return Word


def remove_exclamation_marks(s):
	s = list(s)
	x = 0
	for element in s:
		while True:
			if len(s) == x:
				break
			if s[x] == '!':
				del s[x]
			else:
				break
		x += 1
	s = ''.join(s)
	return s


def remove_exclamation_marks(s):
	new_s = []
	for n in s:
		if n == '!':
			n = ''
		else:
			new_s.append(n)
	answer = ''.join(new_s)
	return answer


def remove_exclamation_marks(s):
	result = ''
	for i in range(len(s)):
		if s[i] != '!':
			result += s[i]
	return result


def remove_exclamation_marks(s):
	print(s)
	answer = s.translate({ord('!'): None})
	return answer


def remove_exclamation_marks(s):
	return ''.join((x for x in s if x is not '!'))