What does the following produce? print('abcd'.translate('a': 1', 'b': 2', 'c': 3', 'd': 4'))
A. 1234
B. abcd
C. blunders
D. none of the aforementioned options are available.
Answer:B
What does the following produce? print('abcd'.translate('a': 1', 'b': 2', 'c': 3', 'd': 4'))
A. 1234 B. abcd C. blunders D. none of the aforementioned options are available.
Explanation: A dictionary of integers is required by the translate function. Instead of the above, use maketrans().