If you are working the text data in a pandas Series, instead of creating your own functions, use series.str to access common methods to process string.
The code above shows how to convert text to lower case then replace “e” with “a”.
Find other useful string methods here.