Learn String Manipulation by Building a Cipher - Step 16

I cant figure out what I’m doing wrong here hope someone can explain what I should do

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.

Your code so far


/* User Editable Region */

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

shifted = index + shift




/* User Editable Region */

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 16

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

Hello Bacro,

Right now what you have done is given the variable shifted the value of index + shift. If you were to print index + shift, you would get the number 10 back.
So now we need to figure out which character in the string alphabet is at location 10 (a.k.a. index + shift).
To find a specific character in a string you would use string_var[int] where string_var is your string variable, and int is the number of the character you want.

I hope this helps, you got this!

3 Likes

REDACTED SOLUTION BY MOD

This is the step expected for step 16

1 Like

welcome @ram.amrita

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.

I’m still confused…the bot deleted the solution

1 Like

No bots in doing this, but if you need help I suggest you open your own topic

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.