Learn String Manipulation by Building a Cipher - Step 12

Tell us what’s happening:

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 use the built-in find() function:

a_string.find(char)

Above, char is the character you want to locate, and a_string is the string you want to parse.

At the end of your code, call find() on your alphabet string and pass text[0] to the function.

Your code so far


/* User Editable Region */

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'


/* 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

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 12

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.

At the end of your code, call find() on your alphabet string and pass text[0] to the function.

Have a look at the example. Did you have a question?

still don’t understand

1 Like

I’m still getting tripped up by the nomenclature, pass text [0] . Call find() is to print, right? So …print(alphabet)) print = ‘alphabet’, I don’t know if I’m getting tripped up here.

I have this code thus far;
text = ‘Hello World’
shift = 3
alphabet = ‘abcdefghijklmnopqrstuvwxyz’ as above example but can’t figure out what they want me to do. I typed
alphabet = “abcdefghilklmnopqrstuvwxyz” That’s good but after that, I’m getting twisted up.

Hi, Use the “ask for help” button to open a topic. It gets too complicated to help multiple people in one thread as they may run into different problems

DELETED Solution

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.

I think the biggest problem is the way the instructions are worded need to be a more simplified way to word a problem especially for new coders that have never seen a particular string of code and something new is being introduced that does a function and the instructions are way out there like a trick question to me there are to many hit and misses. to many unrevealed solutions that seems to be like, you just got to know that. It slows me down when I half to decipher the instructions. Is this the way learning coding needs to be?

You may need to google new concepts for further explanation, or examples. This is a pretty common task for a new or even an experienced programmer who needs to call up some forgotten syntax.

Now that you understand this step, do you have a suggestion for a clearer wording or example for new learners?

I am stuck at this question right now and i am as clueless as you were
so far I have tried

alphabet.find(text[0])
alphabet.find("a')

but i still dont understand what exactly do i need to do
how do i call the find function
do i use print or not

First try looks good. Try it again if it doesn’t work open a new thread

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.