Learn String Manipulation by Building a Cipher - Step 54

Tell us what’s happening:

Hello guys,
I am struggling with 54,

You should pass text and shift as the arguments to your function call by including them inside the parentheses. Don’t forget to separate the arguments with a comma.
Can someone help me with it? thank you

Your code so far

text = 'Hello Zaira'
shift = 3

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

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

# User Editable Region

caesar()

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 54

This is your function call here at the end

def caesar(message=text, offset=shift):

This is your function definition, you shouldn’t change that. You could reset the step and try again.

Hello pkdvalis,
Thank you for the help! :smiley:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.