Build a Caesar Cipher - Step 15

Tell us what’s happening:

please help me how to resolve it, i’ve try several ways, but it’s still not working

Your code so far

def caesar(text, shift):
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    shifted_alphabet = alphabet[shift:] + alphabet[:shift]

# User Editable Region

    translation_table = str.maketrans(alphabet, shifted_alphabet)

# User Editable Region

    return text.translate(translation_table)

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/146.0.0.0 Safari/537.36

Challenge Information:

Build a Caesar Cipher - Step 15

you are not doing as instructions says!! look into error message "...concatenating to each argument the uppercase version of the argument itself."

  • you need to concatenate each argument with its upper case

adjust that and try again, happy coding :slight_smile:

removed by moderator

Your code fails because str.maketrans() only maps lowercase letters, so uppercase letters remain unchanged and are not encrypted.

ok i see, thank u :smiley:

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.

1 Like