Back to Freecodecamp

Step 35

curriculum/challenges/english/blocks/learn-string-manipulation-by-building-a-cipher/65524b790ba8558a2f1c9fe5.md

latest1.2 KB
Original Source

--description--

Clean the output a bit. Delete print(char, index), and turn the last print() call into print('char:', char, 'new char:', new_char).

--hints--

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

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

You should change print(new_char) into print('char:', char, 'new char:', new_char).

js
const commentless_code = __helpers.python.removeComments(code);
assert.isFalse(/print\s*\(\s*new_char\s*\)/.test(commentless_code));
const {block_body} = __helpers.python.getBlock(commentless_code, /for\s+char\s+in\s+text\.lower\s*\(\s*\)\s*/);
assert(block_body.match(/print\s*\(\s*("|')char:\1\s*,\s*char\s*,\s*("|')new\schar:\2\s*,\s*new_char\s*\)\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'

for char in text.lower():
    index = alphabet.find(char)
    print(char, index)
    new_index = index + shift
    new_char = alphabet[new_index]
    print(new_char)
--fcc-editable-region--