Learn String Manipulation by Building a Cipher - Step 50

Tell us what’s happening:

i do the Right after your shift variable, declare a function called caesar and indent all the following lines to give your new function a body.
but when i do that it tells me You should use the def keyword to declare a new function.

Your code so far


# User Editable Region

text = 'Hello Zaira'
shift = 3
    def caesar():
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    encrypted_text = ''
    for char in text.lower():
        print('encrypted text:', encrypted_text)
        if char == ' ':
            encrypted_text += char
        else:
            index = alphabet.find(char)
            new_index = (index + shift) % len(alphabet)
            encrypted_text += alphabet[new_index]
    print('encrypted text:', encrypted_text)


# 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/120.0.0.0 Safari/537.36 OPR/106.0.0.0

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 50

Good, but don’t indent “def”

def my_function():
  print("Hello from a function") 

Indent the body of the function, not the function declaration (def)

https://www.w3schools.com/python/python_functions.asp

Welcome to the forum @dbtippieqp101

Going off advice from @pkdvalis , you also need to only modify the code you are asked.

You moved the first print call.

The tests make specific tests in the code. Altering any part of the code you are not asked will fail the tests.

Please reset the step to restore the original code.

Happy coding

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