Back to Freecodecamp

Step 21

curriculum/challenges/english/blocks/learn-string-manipulation-by-building-a-cipher/65520f8282faf57a0db4f7fe.md

latest950 B
Original Source

--description--

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.

Modify your shifted variable so that it stores the value of alphabet at index index + shift.

--hints--

You should assign alphabet[index + shift] to your shifted variable.

js
assert.match(code, /^shifted\s*=\s*alphabet\s*\[\s*(index|shift)\s*\+\s*(?!\1)(index|shift)\s*\]\s*(#.*)?$/m)

Your code contains invalid syntax and/or invalid indentation.

js
({test: () => assert(true) })

--seed--

--seed-contents--

py
--fcc-editable-region--
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
index = alphabet.find(text[0].lower())
print(index)
shifted = alphabet[index]
print(shifted)
--fcc-editable-region--