Learn String Manipulation by Building a Cipher - Step 16

Tell us what’s happening:

Describe your issue in detail here.
I am having issues understanding how to convert the sum of index and shift to find a letter in the alphabet string

Your code so far


/* User Editable Region */

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

/* 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/119.0.0.0 Safari/537.36 OPR/105.0.0.0 (Edition std-1)

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 Drew,

In step 16, you need to us the alphabet variable to find the character at location index + shift. And store this in a new variable called shifted.

Both shift and index are integers so we can add those to get a single int:

index + shift

Now we would like to find the character in the alphabet that represents this new integer as followed:

alphabet[index + shift]

Then once we’ve done this we would like to assign it to a new variable called shifted.

shifted = alphabet[index + shift]

And there we go, we solved step 16!

You got this! :blush:

2 Likes

thank you, this helped a lot. I thought I needed to fully implement the alphabet.find(text) into the line but it was much simplier. Thank you

Haha yeah I ended up wanting to go too fast on occasions too. :blush:

hey there @HungryBee

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.

Oh no thanks I’m all good.
Appreciated though.

I must be really tired, I wanted to post this instead

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.

2 Likes

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