Let’s see how to remove a character from a string with Python.
Suppose we have a string.
string = 'pythoneo'
What can I do to remove a character from the string?
Just replace it with nothing.
I’d like to remove ‘eo’. Then I need to use replace function and replace it to nothing.
string = string.replace('eo','')
Simple as it is. This is the easiest way to remove a character from string in Python.
string = 'pythoneo' print(string) string = string.replace('eo','') print(string)