Build a Caesar Cipher - Step 15

Tell us what’s happening:

Hello!
I am trying to do the upper case. test says either indentation, then goes back to original question. I have checked as far as I can. Please tell me anything that will help.

Your code so far

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

# User Editable Region

    str.maketrans.upper()+(alphabet.upper()+shifted_.upper()+alphabet.upper())


# 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; rv:145.0) Gecko/20100101 Firefox/145.0

Challenge Information:

Build a Caesar Cipher - Step 15

I suggest resetting this step to restore the original code, then try again. This time, only apply upper() to the arguments passed to the function.

str.maketrans(alphabet.upper + shifted_alphabet.upper())

This one tests unsupported etc… in the console. I need more guidance.

Has upper() been applied to alphabet correctly?

1 Like

Console message : TypeError: if you give only one argument to maketrans it must be a dict

To My code : str.maketrans (alphabet.upper() + shifted_alphabet.upper())

Please help.

From the instructions:

Update your str.maketrans() call by concatenating to each argument the uppercase version of the argument itself.

Your arguments are alphabet and shifted_alphabet, so you need to concatenate alphabet.upper() to alphabet, etc. Make sense?

3 Likes

Here say invalid syntax. Completely lost!

(alphabet.upper()) + (alphabet.upper()) +

(shifted_alphabet:upper()) + (shifted_alphabet:upper())

okay. show me an example of how you would call a function with two arguments. and please explain in your own words what it is this step wants you to do.

1 Like

funtion

x=Y+1

Drop x

attach .upper to y and 1

Add y.upper + 1.upper

Like to add. Thank you for your patience. It’s just confusing.

this is not calling a function with two arguments. this is assigning the value of Y+1 to the variable x.

try again, please.

if you reset the step again, you will see an example of that right there.

i need to go offline for a while. please focus on how to call a function with two arguments and try to better understand what this step wants you to do by reading the instructions over again carefully.

2 Likes

Here say invalid syntax. Completely lost!

(alphabet.upper()) + (alphabet.upper()) +

(shifted_alphabet:upper()) + (shifted_alphabet:upper())

If you reset the step, this is the starting code:

translation_table = str.maketrans(alphabet, shifted_alphabet)

So this is calling a method and passing 2 arguments:

str.maketrans(alphabet, shifted_alphabet)

You need to modify those arguments.

  1. You need to concatenate to each one (good that you are using the concatenation operator)

Here is how to concatenate two variables:

arg + arg

So you’ll need to do this for both of your arguments alphabet and shifted_alphabet

“concatenating to each argument the uppercase version of the argument itself.”

It sounds a bit complicated but the basic structure looks like this:

obj.method(arg + arg.method(), arg2 + arg2.method)

I hope this helps!

1 Like

I have done below and the message in the console is : SyntaxError: unmatched ‘)’ is.

Please help. :slight_smile:

(alphabet. upper(),) + (alphabet. upper(),)

(shifted_alphabet).upper)) + () (shifted_alphabet).upper))

I feel it may be helpful to re-read how to invoke a method and what an empty tuple is. Otherwise: I am not really helping you in the genuine sense that will make you grow as a person.

Can you please explain in your own words what you are trying to do?

I now realize the arguments are alphabet and alphabet_shift. I am concatenating each one separately with their uppers

I now have this

translation_table = str.maketrans(alphabet, +

alphabet,.upper()shifted_alphabet +

shifted_alphabet.upper())

So, now what are your two arguments? What punctuation is used to separate arguments in a function call? What punctuation is used to apply upper()?

You have the right idea, but your syntax around the alphabet variable is messed up and you are not separating the two arguments correctly in your function call.

1 Like