Answers for "python replace list from another dictionary items"

0

python replace list from another dictionary items

>>> subs = {
...         "Houston": "HOU", 
...         "L.A. Clippers": "LAC",
... 
...     }
>>> rev_subs = { v:k for k,v in subs.iteritems()}
>>> [rev_subs.get(item,item)  for item in my_lst]
['L.A. Clippers', 'Houston', '03/03 06:11 PM', '2.13', '1.80', '03/03 03:42 PM']
Posted by: Guest on July-22-2020

Code answers related to "python replace list from another dictionary items"

Python Answers by Framework

Browse Popular Code Answers by Language