Learn String Manipulation by Building a Cipher - Step 39

Tell us what’s happening:

This is not passing though im getting correct output.

Your code so far


# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''

for char in text.lower():
    if char == ' ':
        encrypted_text += char
    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/124.0.0.0 Safari/537.36 Edg/124.0.0.0

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 39

Hi there and welcome to our community!

Also, modify the print() call into print('char:', char, 'encrypted text:', encrypted_text)

Your print() call does not exactly match this.

I did that and it does not proceed what should I do is it a bug?

No, there isn’t a bug in this lesson. Could you share your updated code please?

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''

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

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

there should be 4 lines inside the function, it seems you are going a bit too fast… why did you add the if statement?

1 Like

Thanks for telling they are different (i don’t wear specs)

this shit’s hard so I’m attaching a scrrenshot

Looks like you are back to your original error.

this is what fixed mine

code removed by moderator

hey @christiankrizanovic2

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.