Build a Caesar Cipher - Step 19

Tell us what’s happening:

It says that my code raised an error but it isn’t showing a error in the terminal and shows the proper code. Where is the error here?

Your code so far

def caesar(text, shift):
    if not isinstance(shift, int):
        return 'Shift must be an integer value.'
    

# User Editable Region

    if shift > 1:
        return 'Shift must be a positive integer.'

# User Editable Region


    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    shifted_alphabet = alphabet[shift:] + alphabet[:shift]
    translation_table = str.maketrans(alphabet + alphabet.upper(), shifted_alphabet + shifted_alphabet.upper())
    return text.translate(translation_table)

encrypted_text = caesar('freeCodeCamp', 3)
print(encrypted_text)

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36

Challenge Information:

Build a Caesar Cipher - Step 19

Welcome to the forum @christopher_soun !

create another if statement that checks if shift is less than 1

Are you sure your code meets this requirement?

You should be seeing a message in the console.

Happy coding!

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