Learn String Manipulation by Building a Cipher - Step 43

Tell us what’s happening:

Describe your issue in detail i am stuck at this level, i am following the instructions and improving my code many times but still its not working. Exactly where i have to put that addition .

Your code so far


# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
if char == ' ':
    print(char+=alphabet[new_index])  
index = alphabet.find(char)
new_index = index + shift
encrypted_text+=alphabet[new_index]
    print('char:', char, 'encrypted text:', encrypted_text)
    

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 43

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.
Learning to describe problems is hard, but it is an important part of learning how to code.
Also, the more you say, the more we can help!

1 Like

Hello @simonrilley067,
Welcome to FCC Forum,

You dont need any print becouse!It says instead of printing 'space!'.
Also at the space of print add encrypted_text. and use the additon assignment +=. and put char on it!
Happy coding :grinning:

2 Likes

Welcome to the forum @simonrilley067

Here is a comparison between the original code and your new code.
image

The code in red is your new code.
The code in blue is the original code.
Code in magenta is the overlap.

You appear to have changed the indentation of the code.

Please reset the step to restore the original code.

Now, instead of printing 'space!' , use the addition assignment operator to add the space (currently stored in char ) to the current value of encrypted_text .

So this is the code you need to replace.

    if char == ' ':

Happy coding

2 Likes

I love the way you solved the question!

1 Like

But, How did you create code above!

html: textarea elements
css: position set to absolute, and transparent background.

where can i get that please

thanks brother, i messed up a bit but your answer helped me

1 Like