7.12. strings are mutable

You can change the letters in an string one at a time using the [] operator on the left side of an assignment.

The active code below changes the first letter in greeting to be 'J'.

Notice we are using the same operator ([]) to either get a single character from a string or to modify a single character in the string.

Put together the code below to creater a function <code>mixer<code> that takes in two strings and replaces every even index of the first string by the corresponding index of the second. It returns the modified first string. Example: <code>string_a = “food”<code> and <code>string_b = “summer”<code> . <code> mixer(string_a ,string_b )<code> makes <code>string_a<code> become “somd”.

Assume second string is greater than first.

You have attempted of activities on this page