Learn String Manipulation by Building a Cipher - Step 54

Tell us what’s happening:

It says “You should rename all occurrences of text to message,” but there aren’t any ‘text’ left in the code. So why it isn’t pass?

Your code so far


# User Editable Region

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

    for char in message.lower():
        if char == ' ':
            encrypted_message += char
        elif char in alphabet:
            index = alphabet.find(char)
            new_index = (index + offset) % len(alphabet)
            encrypted_message += alphabet[new_index]
        else:
            encrypted_message += char

    print('Plain message:', message)
    print('Encrypted message:', encrypted_message)

message = "Hello Zaira"
offset = 3
caesar(message, offset)


# 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/131.0.0.0 Safari/537.36 Edg/131.0.0.0

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 54

Inside your function body, rename the text and shift variables to message and offset, respectively.

The variable text, not the word ‘text’. Don’t change the word text in a variable like this:

encrypted_text = ''

Reset the step and try it again.

1 Like

Just inside your function, not out side