Learn String Manipulation by Building a Cipher - Step 16

i dont understand the provided instructions. Please Help.

the instructions : " 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. "

Below is my code so far:
text = ‘Hello World’

shift = 3

alphabet = ‘abcdefghijklmnopqrstuvwxyz’

index = alphabet.find(text[7].lower())

print(index)


/* User Editable Region */

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

/* User Editable Region */

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) 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

hello! @Ahukko

We have to find for the text with index position at 0 like… text[0].

our challenge is to find where the letter ‘H’ from variable text appears in the variable alphabet, its location in the var alphabet. that index is 7.

since H from Hello World is in uppercase we use the lower() function to match with the alphabet variable.

Good luck!

You can also check this post where the same has been discussed.

See you! Good luck!

1 Like

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