Back to Freecodecamp

Step 36

curriculum/challenges/english/blocks/learn-string-manipulation-by-building-a-cipher/655251308f31958d06cdf267.md

latest929 B
Original Source

--description--

At the moment, the encrypted character is updated in every iteration. It would be better to store the encrypted string in a new variable. Before your for loop, declare a variable called encrypted_text and assign an empty string ('') to this variable.

--hints--

You should declare a variable called encrypted_text before your for loop.

js
({ test: () => assert(__userGlobals.has("encrypted_text")) })

You should assign an empty string to your encrypted_text variable.

js
({ test: () => assert.equal(__userGlobals.get("encrypted_text"), "") })

--seed--

--seed-contents--

py
--fcc-editable-region--
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'

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