Tell us what’s happening:
I am completely stumped on this. I need to “Add a third parameter named encrypt to your function and give it a default value of True.”
I thought I could just write def caesar(text, shift, encrypt): after I had added encrypt == True or encrypt = True. I have tried a number of similar thoughts and I can’t seem to connect the example code to what I am supposed to be doing.
Thanks very much for your help!
Your code so far
# User Editable Region
def caesar(text, shift):
# User Editable Region
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'
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 (Macintosh; Intel Mac OS X 10.15; rv:142.0) Gecko/20100101 Firefox/142.0
Challenge Information:
Build a Caesar Cipher - Step 21
https://www.freecodecamp.org/learn/full-stack-developer/workshop-caesar-cipher/step-21