Learn String Manipulation by Building a Cipher - Step 54

Tell us what’s happening:

I don’t got it what am I gotta do there. Who can help me?

Your code so far

text = 'Hello Zaira'
shift = 3

# User Editable Region

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

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

caesar()

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

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 54

:balloon:Hello @asadovtursun1 !

Welcome to the forum!

The function parameters were changed in one of the previous steps. Now, for the function to continue to work properly, it needs to reference the new parameter names instead of the old ones.

So, wherever you see the word text you need to replace it with the word message. Wherever you see the word shift, replace it with the word offset.

Does this help?

Keep up the good progress!

Happy Coding! :slightly_smiling_face:

1 Like

you forgot to change the word shift here

2 Likes

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