Insert some string into given string at given index

An important point that often bites new Python programmers but the other posters haven’t made explicit is that strings in Python are immutable — you can’t ever modify them in place.

You need to retrain yourself when working with strings in Python so that instead of thinking, “How can I modify this string?” instead you’re thinking “how can I create a new string that has some pieces from this one I’ve already gotten?”

Leave a Comment