String manipulation step 13. Not sure what am I missing

So I saw other responses where they added index = My question is where do they get index from? Isn’t mention in the instructions. I also copied the same code, but it seems I’m doing something wrong. Thank you!

text = ‘Hello World’

shift = 3

alphabet =‘abcdefghijklmnopqrstuvwxyz’

index = aphabet.find(text[0])

Hi, Xio. I am not sure I understand your doubt, but I’ll try my best.

“index” is a new variable- it’s just named “index” because it represents, well, the index in the alphabet!

About your code, as far as I know, it’s fine. Are you sure you’re not applying this code to the wrong step? Maybe 14 or 15?

Hope that helps, God bless!

1 Like

What are the instructions you’re following?

Do you have any errors or hints?

1 Like

if you look at forum topics too old you get topics referencing old versions of the step, that’s why things do not match

in this step you do not need to create a new variable

1 Like

Below are the instructions. So I changed the code to this:

index = text.find (alphabet)
and I’m getting this:

You should call the .find() method on the alphabet variable.

Step 13

The first kind of cipher you are going to build is called a Caesar cipher. Specifically, you will take each letter in your message, find its position in the alphabet, take the letter located after 3 positions, and replace the original letter with the new letter.

Start by finding the position of the first letter in the string. One way is to call the .find() string method on the string you want to parse:

text.find('W')

Above, uppercase 'W' is the character you want to locate inside the string stored in the text variable. The method will return 6, which is the index of the 'W' character inside the string stored in the text variable.

At the end of your code, call .find() on your alphabet string and pass text[0] to the method. Note that a method is just a function that belongs to an object (you will learn more about that in another project).

aphabet.find(text[0])

Sorry just noticed the typo here in alphabet. This is the correct syntax to call find on alphabet and pass text[0]. Just correct the spelling for alphabet

1 Like

I’m getting this now :
You should call the .find() method on the alphabet variable and pass text[0] to the method. Pay attention to place the method call at the beginning of the line.

can you share your current code?

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