[Solved] Python dictionary subset


Update: for multiple dictionaries

Iterate over your dictionaries and for every one of them, check if the value of ‘mesic’ is in [6,7,8] and if so, get the corresponding dictionary values:

d1 = {'stat': u'AS', 'vyska': 3.72, 'stanice': u'AQW00061705', 'mesic': 8, 'teplotaC': 26.88}
d2 = {'stat': u'AS', 'vyska': 3.72, 'stanice': u'AQW00061705', 'mesic': 1, 'teplotaC': 26.88}
list_of_dicts = [d1, d2]

for dic in list_of_dicts:
    if dic['mesic'] in [6,7,8]:
        print(dic['stat'], dic['teplotaC'])

1

solved Python dictionary subset