Back to Freecodecamp

Step 22

curriculum/challenges/english/blocks/learn-string-manipulation-by-building-a-cipher/659db3e3670d3e712be82593.md

latest2.0 KB
Original Source

--description--

Repeating the process of locating the letter inside the alphabet and determine the shifted letter for each character in text can be tedious. Thankfully, you can simplify it using a loop.

For now, remove all the lines of code below the declaration of the alphabet variable.

--hints--

You should still have text = 'Hello World' in your code.

js
const commentless_code = __helpers.python.removeComments(code);
assert.match(commentless_code, /^text\s*=\s*("|')Hello World\1/m)

You should still have shift = 3 in your code.

js
const commentless_code = __helpers.python.removeComments(code);
assert.match(commentless_code, /^shift\s*=\s*3/m)

You should still have alphabet = 'abcdefghijklmnopqrstuvwxyz' in your code.

js
const commentless_code = __helpers.python.removeComments(code);
assert.match(commentless_code, /^alphabet\s*=\s*("|')abcdefghijklmnopqrstuvwxyz\1/m)

You should delete index variable and its value.

js
const commentless_code = __helpers.python.removeComments(code);
assert.notMatch(commentless_code, /index\s*=/)

You should not have print(index) in your code.

js
const commentless_code = __helpers.python.removeComments(code);
assert.notMatch(commentless_code, /print\s*\(\s*index\s*\)/)

You should delete the shifted variable and its value.

js
const commentless_code = __helpers.python.removeComments(code);
assert.notMatch(commentless_code, /shifted\s*=/)

You should not have print(shifted) in your code.

js
const commentless_code = __helpers.python.removeComments(code);
assert.notMatch(commentless_code, /print\s*\(\s*shifted\s*\)/)

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 + shift]
print(shifted)
--fcc-editable-region--