The function str.replace(old, new[, max])
don’t changes c
string itself (wrt to c
you calls) just returns a new string which the occurrences of old have been replaced with new. So newstr
just contains a string replaced by last vowel in c
string that is the o
and hence you are getting "Hey lk wrds"
that is same as "Hey look words".replace('o', '')
.
I think you can simply write anti_vowel(c)
as:
''.join([l for l in c if l not in vowels]);
What I am doing is iterating over string and if a letter is not a vowel then only include it into list(filters). After filtering I join back list as a string.