Learn String Manipulation by Building a Cipher - Step 49

Tell us what’s happening:

I am a bit confused as to why it isn’t passing, On line 16 do i switch text with message on both ‘encrypted text:’ and encrypted_text? isn’t the underscore representing a space, without actually having a space?
I had noticed when clicking on Text or shift and waiting for a moment, it will highlight the other matches of the word, I am assuming it i showing all the different places it is referenced? Can I use that to guide?

Your code so far

/* User Editable Region */

text = 'Hello Zaira'
shift = 3

def caesar(message,offset):
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    encrypted_text = ''

    for char in message.lower():
        if char == ' ':
            encrypted_text += char
            index = alphabet.find(char)
            new_index = (index + offset) % len(alphabet)
            encrypted_text += alphabet[new_index]
    print('plain message:', message)
    print('encrypted message:', encrypted_text)


/* User Editable Region */

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 49

1 Like


The problem is that you changed “plain text” to “plain message”.
This string is supposed to stay the same, just the “text” variables are to make place for the new parameter “message”.

This might be confusing and illogical at first, but shows how important it is to know the different data types we are working with and learn to separate their inherent logic. This comes with experience.

“encrypted_text” is a different variable, the underscore is a practice to name variables containing multiple words.

Thank you Daniel! :hearts: :hearts:

You are welcome, you have to keep both strings the same btw!

1 Like

Thank you and yes, this really don’t make any sense. It would be nice if everything is more described in the Steps, so we are not going to ask here in this forum :slight_smile:

This project is in beta and is currently being modified