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 = str(3)
alphabet = 'abcdefghijklmnopqrstuvwxyz'
index = alphabet[7]
shifted = index + shift
 

what am i supposed to do so the code can run?
I mean haven't i created the "shifted" variable right??





/* User Editable Region */

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.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.

The question is: Declare a variable named shifted and assign it the alphabet letter at index plus shift

SOLUTION

first declare a variable call “shifted”

use the assignment operator “=” to assign it a value.

now you need to figure out the value. the letter we are looking for is in the position of “index + shift” in the alphabet variable.

access that position with the use of square bracket “[ ]” remember it is in the alphabet variable that you will be looking for this letter.

Please if you find it difficult finding the solution from here kindly reach out, as we will be ready to be of assistance.

does this mean the code will look like this?
shifted = alphabet[index + shift]

1 Like

Try it let’s see what will happen. Congratulations in advance.

1 Like

Thanks a lot I got it