Build a Caesar Cipher - Step 22

Tell us what’s happening:

Sono allo step 22 per il cifrario di Cesare.
def caesar(text, shift, encrypt=True):
if not encrypt:
shift = -shift
dovrebbe essere giusta ma a quanto pare non mi fa andare avanti perchè dice che ci sono errori, inoltre se guardo lo schermo sulla destra mi dice che il modulo 14 e l’alfabeto non è definito, quando in realtà sono tutti i moduli precedenti. Cosa posso fare? Grazie a chi mi aiuterà

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'
    

# User Editable Region

def caesar(text,shift,encrypt=True):
    if not encrypt: 
        shift = -shift

# User Editable Region

    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


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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36

Challenge Information:

Build a Caesar Cipher - Step 22

non devi ricreare la funzione in questo step, la funzione esiste già

puoi aiutarmi per favore?

di che aiuto hai bisogno? se è per questo step 22, raccontaci che cambiamenti hai fatto, se è per un’altra sfida perfavore crea un altro topic

code removed by moderator

hi @aoc82500

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.