Sail E0 Webinar
Question
What is the output of the following?print('abcd'.translate({'a': '1', 'b': '2', 'c': '3', 'd': '4'}))
Options:
A .  abcd
B .  1234
C .  error
D .  none of the mentioned
Answer: Option A


The function translate expects a dictionary of integers. Use maketrans() instead of doing the above.



Was this answer helpful ?

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers