xxxxxxxxxx
import re
inputt = input()
# write the characters you want to remove in square brackets
line = re.sub('[ie]', '', inputt)
print(line)
xxxxxxxxxx
a_string = "addbdcd"
a_string = a_string.replace("d", "")
print(a_string)
xxxxxxxxxx
# Simply use this function
def RemoveChars(string, what_to_remove): # what_to_remove should be a list containing the characters
s = "".join(c for c in string if c not in list("".join(what_to_remove)))
return s.strip()
my_string = "All.Good,Dogs.. Eat.! Shoes?"
things_to_remove = [',', '.', '!']
final = RemoveChars(my_string, things_to_remove)
print(final)
>>> 'AllGoodDogs Eat Shoes?'
xxxxxxxxxx
>>> string = 'This is a string, with words!'
>>> string.split()
['This', 'is', 'a', 'string,', 'with', 'words!']
xxxxxxxxxx
s = 'This is a sentence with unwanted characters.AAAAAAAA'
print('Strip unwanted characters: {}'.format(s.rstrip('A')))
# Output
# Strip unwanted characters: This is a sentence with unwanted characters.
xxxxxxxxxx
mystring = "123⋯567"
mystring[ 0 : mystring.index("⋯")]
>> '123'