Learn String Manipulation by Building a Cipher - Step 16

Tell us what’s happening:

Describe your issue in detail here.

Your code so far


/* User Editable Region */

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
Index = alphabet.find(text[0].lower())
index = alphabet[Index]
print(index)
shift= alphabet[shift]
shifted = index + 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/119.0.0.0 Safari/537.36 OPR/105.0.0.0

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 16

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

Hello Nebuleous,

I would strongly not recommend using the same variable name but differently capatalized as that’s going to get confusing very fast.

Anyway, the question doesn’t ask you to change any of the original code except adding a new variable called shifted, in which you need to get the alphabet letter at index plus shift.
It seems like you already understood how to get letters out of alphabet using one variable. But did you know that if for example you wanted to get the 3rd letter of a string you can also do string_var[2+2] this question uses the same concept, but instead it uses index + shift and not direct integers.

I hope this helps, but if not please feel free to ask more questions.

3 Likes

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