Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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']
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #replace #list #dictionary #items
ADD COMMENT
Topic
Name
7+2 =