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.
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
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:
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)
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?