Learn String Manipulation by Building a Cipher - Step 27

I have been told:
Strings are immutable, which means they cannot be changed once created.

Use bracket notation to access the first letter in text and try to change it into a character of your choice.

What I have done so far is

User Editable Region

text = ‘Hello World’
new_char=‘j’
new_text=new_char+text[1:]

User Editable Region

shift = 3
alphabet = ‘abcdefghijklmnopqrstuvwxyz’

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

I have also tried
text=‘hello world’
text=‘y’+text[0:]

and this did not work, what am I doing wrong?

Welcome @harjodh69 to FCC community

the correct syntax is

variablename[index]

here text is variable name and as per instruction u need to change index of first character. so index of first character is 0.

after following syntax and replacing it correctly assign any letter inside '' quotes to it.

I have tried:
text = ‘Hello World’

text[index(0)]=‘y’

And it still does not work

remove index and ()

variablename[index]

see here u need to replace index with 0

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