Build a Caesar Cipher - Step 25

Tell us what’s happening:

hello i can’t exactly figure out whats happening with this code at step 25.Please can i have some assistance from another perspective

Your code so far

def caesar(text, shift, encrypt=True):

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

    if shift < 1 or shift > 25:
        return 'Shift must be an integer between 1 and 25.'

    alphabet = 'abcdefghijklmnopqrstuvwxyz'

    if not encrypt:
        shift = - shift
    
    shifted_alphabet = alphabet[shift:] + alphabet[:shift]
    translation_table = str.maketrans(alphabet + alphabet.upper(), shifted_alphabet + shifted_alphabet.upper())
    encrypted_text = text.translate(translation_table)
    return encrypted_text

def encrypt(text, shift):
    return caesar(text, shift)
    
def decrypt(text, shift):
    return caesar(text, shift, encrypt=False)


# User Editable Region

encrypted_text = encrypt('Pbhentr vf sbhaq va hayvxryl cynprf.',13)
print(encrypted_text)

decrypted_text = decrypt(encrypted_text,13)
print(decrypted_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/144.0.0.0 Safari/537.36

Challenge Information:

Build a Caesar Cipher - Step 25

Can you be more specific about what you don’t understand?

The exercise required that i should place the “Pbhentr vf sbhaq va hayvxryl cynprf.” as the parameters in the call of encrypt function . Then during the call of the decrypt function i should pass the value of the encrypted text as a parameter for the decrypt function. However, when i did both but it does not pass the test.

are you sure?
It says

Replace the value assigned to encrypted_text with the following string,

that does not say to replace the argument of the function, it says to replace the whole value assigned to encrypted_text

1 Like

Thansk for this outlook, i now see clearly what was asked. This solved the issue.