Learn String Manipulation by Building a Cipher - Step 27

Tell us what’s happening:

Having trouble understanding how to ‘change’ to a different char

Your code so far

text = ‘Hello World’
text[0] = text.char(‘y’)

# User Editable Region

text = 'Hello World'
text[0] = text.char('y')

# User Editable Region

shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'

for char in text.lower():
    index = alphabet.find(char)
    print(char, index)
    new_index = index + shift

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 27

Hey @trottiemcqueen,

This challenge is meant to illustrate that strings cannot be changed by accessing individual characters like an array and changing them because they’re immutable. All it wants you to do is try to access the first character in text (which you are doing), and try to set it to another character. You don’t need anything other than a string with any character in it you wish.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.