Learn String Manipulation by Building a Cipher - Step 16

Tell us what’s happening:

I’m not sure why this code isn’t working? The variable shifted stores the value ‘k’ which is what it says should be done?

Your code so far


/* User Editable Region */

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
index = alphabet.find(text[0].lower())
print(index)
shifted = alphabet[alphabet.find(text[0].lower()) + shift]
print(shifted)


/* User Editable Region */

Your browser information:

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

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 16

in variable shifted u don’t need to make this much complication. Assign variable shifted with string_variable[a+b] where a and b are indices. Remove

no need for this line.

Wait so the problem was i rewrote the value of the variable index again instead of using the variable itself? It worked once I assigned shift to alphabet[index + shift] - Thanks for the help

Yes in ur earlier response u rewrote the value of index.

Happy to hear u passed :smile:

1 Like