Learn String Manipulation by Building a Cipher - Step 16

I cannot figure out what this is asking and every other question/answer on the forum is not helpful.

Looking for a better explanation and guidance here please

Code so far:

text = 'Hello World'

shift = 3

alphabet = 'abcdefghijklmnopqrstuvwxyz'

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

print(index)

shifted = index + shift

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 16

What specifically about the instructions is confusing? Please don’t just copy-paste the instructions but instead talk about what has you stuck

After looking at all the other forums it seems we are confused that looks like it’s asking us to calculate the two numbers. Which would be 10.

I don’t follow.

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

This isn’t talking about 10 anywhere? I don’t see you using the alphabet in your code but the instructions mention it, so that’s probably a problem.

The alphabet letter at index, to me, is implying the index variable.

What does “assign it the alphabet letter at index” mean then?

You need to use the alphabet variable. Otherwise, why would the instructions mention that variable an all.

What type of data is stored in the alphabet variable?

its a string.

I have now tried this because I’m kind of following what you are saying but still lost as this code doesn’t work either.

shifted = (alphabet.find(text[7].lower()) + shift)

You shouldn’t be making a function call here.

You have a string. To get a single character out of a string, you need to ‘index into’ the string, like you indexed into the string ‘text’

shifted = alphabet.find(text[7].lower()) + alphabet.find(shift)

I’m trying here! lol

I don’t understand what it is asking

Don’t use find.

Again… How did you index into the ‘text’ variable? What did you use specifically right next to the text variable to get the 8th character?

I used [7] to get to the 8th character. But I’m using the find function to look for it.

you used [7] to get the 8th character of one string, and used the find function to find it in a different string

you want to use bracket notation when you have the index

Don’t think about find. Don’t use find. This step is not about find.

Using text[7] indexes into the text variable.

You need to do something similar for the alphabet variable.

1 Like

shifted = alphabet[7] + shift

This isn’t working either.

you need to use the two variables to calculate the new index

1 Like

what does this mean? There are 4 different variables.

I was told not to use find, but in order to “find” the value of shift then we need to find that value in alphabet, then add them together.

The instructions name two specific variables to calculate the new index

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

shifted is the only variable that it’s stating to name.

There are 4 variables there. You can tell because they are in a different font

1 Like

well now I tried to dial down to just the alphabet and I’m not getting anywhere.

index = alphabet[7]

shifted = index + shift