I want to write a code that will replace certain characters in a list in an efficient way using a dictionary.
If I have:
key = {'a':'z','b':'y','c':'x'}
List = ['a','b','c']
How can I get the output
zyx
edit to clarify. The output I want is really
randomvariableorsomething = ['z', 'y', 'x'] My apologies.
Will [key[x] for x in List] work if I don't have a key for it in the dict?
['a', 'b', 'w']?