Learn String Manipulation by Building a Cipher - Step 16

Tell us what’s happening:

I try to write the program about shifting the index. This is the description of that program that I try to make:
" 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."

I tried all things but it shows that I have to " assign the alphabet letter at the index index + shift to your new variable." How can I do that?

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)
print(index)

/* 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/120.0.0.0 Safari/537.36 Edg/120.0.0.0

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 16

Hey, here index and shift are numerical indexes, that is numbers. You need to use their sum to access the character in alphabet at that specific index. You should assign that character to shifted, not the sum index + shift.
Have a look at the line of code in which you defined index. You already know how to access characters in a string because you’ve already done it there.

Hello, I used:

shifted = alphabet.find(index + shift)

and it does not come out correct. What else am I missing?

hey @brianacv01

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

1 Like

Was anyone able to figure this one out? I always get caught on what exactly is being asked. I guess its a beginner thing but I can’t seem to understand what the question is asking.

hey @oscardmoreno

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

Hello @ilenia, well the “Ask for Help” tells me if the question has not been asked in the forum, to create a post, but the question has been asked, which is this post…

if existing posts do not answer your question, please create your own to ask your question

Oh okay, thank you! @ilenia

Hello, i figured it out thanks to the help of a friend. The prompt is asking to identify the letter in the string alphabet that is the sum of index + shift (which is 10). I think most of us believed it was asking to identify it numerically. So in order to identify the letter, index and shift have to be in brackets. like so:

Solurion removed by moderator

and it should work!

1 Like

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Thanks @brianacv01 I literally figured it out before I got back on the forum. Thank you!