Learn String Manipulation by Building a Cipher - Step 27

Tell us what’s happening:

It’s saying: You should assign a character of your choice to text[0] .

Your code so far


/* User Editable Region */

text = "hello world"
p = text[0]
newletter = 'X'  # You can replace 'X' with any character you prefer
text = newletter + text[0]

# Now, p will be the updated first letter of text
p = text[0]


/* 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:

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 27

I suggest you to use the reset button before trying again. Assign a character of your choice to text[0] means that text[0] should be on the left side of the assignment operator. Also, the character needs to be a string.

1 Like

You are assigning text[0] to a variable

You should assign a character of your choice to text[0] .

i’m still confused but here is what i tried but it didn’t work:
text = ‘Hello World’
text[0] = p

It does not work because p is not a string.

1 Like

THANK YOU SM, IT WORKS NOW

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