In the following example, I would have expected an error saying that string assignment is not possible because strings are immutable. Instead, the loop returns the original string.
a = "AECD"
for i in a:
if i == "E":
a.replace(i, "B")
print(a)
Is replace not essentially trying to do the same thing as a[1] = "B"? Does this have to do with creating a new object with assignment versus modifying an existing one with replace?