I have a set dictionary like so:
d = {'cat': 'one', 'dog': 'two', 'fish': 'three'}
Given a list, can I just keep the key, values given?
Input:
l = ['one', 'three']
Output:
new_d = {'cat': 'one', 'fish': 'three'}
https://stackoverflow.com/questions/65894523/python-select-key-values-from-dictionary-corresponding-to-given-list January 26, 2021 at 09:00AM
没有评论:
发表评论