Build a Caesar Cipher - Step 20

Tell us what’s happening:

I believe that i have it the way it wants me to but its not working.
i don’t know why it is running into an error

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.'
    if shift > 25 :
        return 'Shift must be an integer between 1 and 25.'

# 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; Linux x86_64; rv:143.0) Gecko/20100101 Firefox/143.0

Challenge Information:

Build a Caesar Cipher - Step 20

Welcome to the forum @joshuaparker17183

Carefully read the instructions.

Add a second condition to the if statement that verifies that shift is greater than 25. Remember that the logical OR operation in Python is implemented through the or operator.

You are not asked to add a second if statement.

Happy coding

1 Like