Learn String Manipulation by Building a Cipher - Step 16

I am stuck on step 16, I don’t really understand what I’m trying to do here

Your code so far


/* User Editable Region */



text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
index = alphabet.find(text[0].lower())
index_number = alphabet.find(text[10])
shifted = (index_number) + (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

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 16

Hello! @m.elhuseyin

First, we are creating two variables “text” and “shift”. Then, we are creating a variable named “alphabet” and “index”.

In “index” variable we are trying to find the index/location of the “text[0]” (text variable) ie… the first element of the “Hello World” (h) in the alphabet variable using “alphabet.find()”. We use the lower() to convert it to the lower case.

Then we print the “index” variable. Now, In step-16 we are using the “+” operator to find the letter at index, “index + shift” which is “h + 3”.

So, we are creating a new var named “shifted” and assign it to “index variable + shift variable” along with the alphabet variable. Try to include the alphabet var with index + shift.

Hint:

hint
word = "kite"
shift = 2
text = "flyskyhigh"

index = text.find(word[0])

print(index) # index = 4

shifted = text[index + shift]  # k + 2 which is h we include the text[]

print(shifted)

You can check for solution here:

REDACTED BY MOD

PS: Sorry for such a long explanation. Happy Coding! :slight_smile:

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.

hello! @ILM

Ok, I thought hiding it, is allowed. Are explanations of a code allowed…?

Thankyou!

PS: I am new to the forum

you can give all the help you want that is not give the exact code to copy and paste in the editor to pass the step

Ok :+1: Thankyou! I got it now.

Thank you for the help!

1 Like

THANK YOU SO MUCH! LITERALLY I WAS STUCK LIKE FOR 30 MINS! But seriously, you are the man thank you for helping me and others out, we really appreciate your help :smiley:

2 Likes

Welcome! Happy Coding! :+1:

1 Like

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