Translate - need help

Hi, need help. I am asked to call the translate() method on text passing in the translation_table as the argument and assign the result to a variable named encrypted_text. So I do the following:

encrypted_text = str.maketrans(text, translation_table)
both text and translation_table are already named variables

the system tells me I need to name encrypted_text. that is what I am doing, right?

I’m guessing you are Step 8 of the Caesar Cipher workshop challenge?

This is the instruction.

Call the translate() method on text passing in the translation_table as the argument and assign the result to a variable named encrypted_text

And this is your code for that.

Does the instruction ask you to pass more than one argument to translate()?
Does the instruction ask you to call translate() on str?

In the future, if you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

Sorry, I do not understand.

The function translate() is called through str.maketrans(), right? At least, that is what I read on FCC. And are you suggesting that I would pass more than one arguments? I need to use one into another for the translate function, right?

The only reaction I get is: You should have a variable named encrypted_text.. It does not say that the use of the function would be wrong, but that I would not have a variable named encrypted_text, which I understand even less.

right now it does only lowecase letters, this step is to make it work with both lowercase and uppercase letters by passing it the lowercase alphabet concatenated to the uppercase alphabet

post your code, we are unable to see your code if you don’t share it with us

I am asked to call the translate() method on text passing in the translation_table as the argument and assign the result to a variable named encrypted_text. So I do the following:

encrypted_text = text.maketrans(translation_table)

As an answer, I get:

You should assign text.translate(translation_table) to encrypted_text.

share all your code and a link to the step

alphabet = ‘abcdefghijklmnopqrstuvwxyz’

shift = 5

shifted_alphabet = alphabet[shift:] + alphabet[:shift]

translation_table = str.maketrans(alphabet, shifted_alphabet)

text = ‘hello world’

encrypted_text = text.maketrans(translation_table)

What do you mean with a link to the step?

Step 8

The translate() method takes as argument the translation table generated by str.maketrans(). It is called on a string and returns a copy of the original string where the characters have been replaced based on the translation table:

Example Code
t = str.maketrans('lk', 'br')
sentence = 'The tent gave in to the leaks.'

print(sentence.translate(t))
# Output: The tent gave in to the bears.

Call the translate() method on text passing in the translation_table as the argument and assign the result to a variable named encrypted_text.

copy the address of the webpage from the browser url bar and paste it here (this is all info that would come automatically when you use the help button)

you are not using translate in your code

What do you mean? It is the first time I hear about the function translate, and I use the syntax as mentioned in the example - make.trans() What else should I use?

Do I have to use this? encrypted_text = text.translate(translation_table)

you should use the other syntax mentioned in the example, the one that is introduced in this step

No. You have passed two arguments to maketrans(), but you should pass only one and you should be calling maketrans() on text, not str.