Learn String Manipulation by Building a Cipher - Step 16

Tell us what’s happening:

so i have typed this in a few different this was my final before i decided to ask for help

Your code so far


/* User Editable Region */

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



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

Use this format:

variable = string[var1 + var2]

Find the character in the string alphabet at the position index + shift and assign it to the variable shifted

I tryed using that format but still no results I am lost

Let’s see it, can you please share your code?

sure will do


text = 'Hello World'

shift = 3

alphabet = 'abcdefghijklmnopqrstuvwxyz'

index = alphabet.find(text[0].lower())

print(index)

shifted = "h" [index + shitf]

you need to access the alphabet string

how would i code that im guessing it would be formatted like this shifted = [alphabet + index]

no, you start with alphabet, then you use the brackets with a number inside to say which character inside alphabet you want

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

you can use a syntax like this:

variable = string[var1 + var2]

so alphabet[7+shift} I have typed this code in so many different ways

okay I am going to try it out

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