I'm trying to remove a set of characters from a larger string. Here's what I've tried:
string = 'aabc'
remove = 'ac'
for i in remove:
string.replace(i, '', 1)
print(string)
I keep getting back my original string when I run this. The variable i
is getting the characters 'a' and then 'c'. The replace function works for me if i do string.replace('a', '', 1)
. Why isn't this working or is there a simpler way to do this?