Learn String Manipulation by Building a Cipher - Step 16

Tell us what’s happening:

Step 16
As you can see from the output, "h" is at index 7 in the alphabet string. Now you need to find the letter at index 7 plus the value of shift. For that, you can use the addition operator, +, in the same way you would use it for a mathematical addition.

Declare a variable named shifted and assign it the alphabet letter at index plus shift.

done this much code so far cant get past this now

Your code so far

/* User Editable Region */

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

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 16

// running tests You should assign the


letter at the index

index + shift

to your new variable. // tests completed

gives me error

You should assign the value of alphabet at the index index + shift to the shifted variable.

You need to use the square bracket notation to access the right index of alphabet, in a similar way as you already did before:

what does this mean? i read this 20 times and still dont get it

Right now, shifted is a number (the sum of index + shift).
You need to use that sum (index + shift) to access a character in alphabet.
How do you access the value located at a specific index within a string?

[0 ] where do i put it

You don’t need [0]. You have to place the square bracket after alphabet and put index + shift in them. This is what you need to assign to shifted.

alphabet [ index + shift ] = ‘abcdefghijklmnopqrstuvwxyz’
did that was wrong.
do i need to make a new line?

Leave this line as it is:

The only thing you need to change is the right part of this:

fk im dumb
thanks :slight_smile:

Mod Edit: Removed Solution