# Elvis.py Copyright (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-05-24 File created. # 2022-12-16 Converted to Python 3. # This program demonstrates how a list of characters can be # used. The list of characters is actually a list of single- # character strings. # Strings cannot be modified because they are immutable sequences. # Lists, on the other hand, are mutable sequences that can be # modified. # If we want to modify a string like the one below, we can convert # the string into a list with the list() built-in function. # When we want to print the modified text, we can convert the # list of characters back to a string with the string method join(). character_positions = "0123456789012345678901" elvis_sentence = list( "Elvis was a rock star." ) print( "\n " + character_positions ) print( "\n " + "".join( elvis_sentence ) ) elvis_sentence[ 12 ] = 'm' elvis_sentence[ 14 ] = 'v' elvis_sentence[ 15 ] = 'i' elvis_sentence[ 16 ] = 'e' print( "\n " + "".join( elvis_sentence ) )