Back to Freecodecamp

Step 34

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

latest844 B
Original Source

--description--

Next, print new_char and see the output.

--hints--

You should print your new_char variable.

js
assert.match(code, /print\s*\(\s*new_char\s*\)/)

You should print your new_char variable at the end of your loop body.

js
({test: () => {
    const commentless_code = __helpers.python.removeComments(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*new_char\s*\)\s*$/));
  }
})

--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]
--fcc-editable-region--