in form lettersnotice that this time we simply printed the resultinstead of assigning it to name--you need to assign results to names only if you want to retain them for later use if you need to replace one fixed-size string that can occur at any offsetyou can do replacement againor search for the substring with the string find method and then slices 'xxxxspamxxxxspamxxxxwhere find('spam'search for position where occurs at offset [:where'eggss[(where+ ): 'xxxxeggsxxxxspamxxxxthe find method returns the offset where the substring appears (by defaultsearching from the front)or - if it is not found as we saw earlierit' substring search operation just like the in expressionbut find returns the position of located substring another option is to use replace with third argument to limit it to single substitutions 'xxxxspamxxxxspamxxxxs replace('spam''eggs''xxxxeggsxxxxeggsxxxxs replace('spam''eggs' 'xxxxeggsxxxxspamxxxxreplace all replace one notice that replace returns new string object each time because strings are immutablemethods never really change the subject strings in placeeven if they are called "replace"the fact that concatenation operations and the replace method generate new string objects each time they are run is actually potential downside of using them to change strings if you have to apply many changes to very large stringyou might be able to improve your script' performance by converting the string to an object that does support in-place changess 'spammyl list(sl [' '' '' '' '' '' 'the built-in list function (an object construction callbuilds new list out of the items in any sequence--in this case"explodingthe characters of string into list once the string is in this formyou can make multiple changes to it without generating new copy for each changel[ 'xl[ ' string fundamentals works for listsnot strings