Why doesn't Python return an error for string assignment using replace in a for loop? : <p>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.</p>

<pre><code>a = "AECD"

for i in a:
    if i == "E":
        a.replace(i, "B")
        print(a)
</code></pre>

<p>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?</p>
