Build a Caesar Cipher - Step 15

Tell us what’s happening:

I am stuck on step 15 of the caesar cypher. It is asing me to modify the strings passes to the str.maketrans() cal using the upper () method. I feel like i have tried everytthing but still get an error

Your code so far

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

# 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/143.0.0.0 Safari/537.36

Challenge Information:

Build a Caesar Cipher - Step 15

What have you tried? I see no change.

Hi,Thanks for helping.

i believe it is asking me to alter the arguements passing to the str.maketrans function

i have tried alphabet +=alphabet.upper()

i have tried alphabet =alphabet.upper() and the same changes to shifted_alphabet but the error remains the same.

You should modify the arguments of your str.maketrans() call by concatenating to each argument the uppercase version of the argument itself. I am not sure if i understand what it means by concatenating.

It is :+1:

So what was your full line? Like this?

translation_table = str.maketrans(alphabet +=alphabet.upper(), shifted_alphabet)

Would you ever use = more than once on a single line?

a = b + c
a = b += c

Did you try searching for an explanation?

https://duckduckgo.com/?q=python+concatenate

i have sorted it. I just changed alpahabet = alphabet + alphabet.upper() and the same for the shifted_alpahbet .

Thank you for pointing me in the right direction

1 Like

removed by moderator

This thread is already marked as solved.

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.