def copyf(data, key, allowed):
    return [x for x in data if key in x and x[key] in allowed]
dictlist = [{'first': 'James', 'last': 'Joule'}, {'first': 'James', 'last':
    'Watt'}, {'first': 'Christian', 'last': 'Doppler'}]
copyf(dictlist, 'first', ('Christian',))
copyf(dictlist, 'last', ('Christian',))
copyf(dictlist, 'first', ('James',))
How to filter list of dictionaries with matching values for a given key