Learn String Manipulation by Building a Cipher - Step 50

Tell us what’s happening:

i tried printing it and i have no idea what is going on so can anyone please help me?

Your code so far


text = 'Hello Zaira'
shift = 3

def caesar():
    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):


# User Editable Region

print("alphabet")

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.134 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 50

Hi @moboy2000

  1. You should attempt to print the alphabet variable outside the caesar function.

Your code is printing a string.

Happy coding