I have one list and one dictionary. I want to compare the list values with the keys of the dictionary. If I have:
mydict = {'Hello':1,'Hi':2,'Hey':3}
mylist = ['Hey','What\'s up','Hello']
output = [3, None, 1]
[mydict[i] for i in mylist]
Use a list comprehension:
output = [ mydict.get(key) for key in mylist ]
Note that dict.get returns None
if the key is not in the dict.