Back to Freecodecamp

Step 26

curriculum/challenges/english/blocks/learn-string-manipulation-by-building-a-cipher/65521fc818947e800bffe48a.md

latest1.1 KB
Original Source

--description--

Inside the for loop, before printing the current character, declare a variable called index and assign the value returned by alphabet.find(char) to this variable.

--hints--

You should declare a new variable named index at the beginning of your for loop.

js
const commentless_code = __helpers.python.removeComments(code);
const {block_body} = __helpers.python.getBlock(commentless_code, /for\s+char\s+in\s+text\s*/);
assert(block_body.match(/^\s*index\s*=/));

You should assign alphabet.find(char) to your new index variable.

js
const commentless_code = __helpers.python.removeComments(code);
const {block_body} = __helpers.python.getBlock(commentless_code, /for\s+char\s+in\s+text\s*/);
assert(block_body.match(/index\s*=\s*alphabet\.find\s*\(\s*char\s*\)\s*(#.*)?$/m));

Your code contains invalid syntax and/or invalid indentation.

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

--seed--

--seed-contents--

py
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
--fcc-editable-region--
for char in text:
    print(char)
--fcc-editable-region--