python dictionary select multiple keys code example
Example 1: only keep few key value from dict
>>> dict_filter = lambda x, y: dict([ (i,x[i]) for i in x if i in set(y) ])
>>> large_dict = {"a":1,"b":2,"c":3,"d":4}
>>> new_dict_keys = ("c","d")
>>> small_dict=dict_filter(large_dict, new_dict_keys)
>>> print(small_dict)
{'c': 3, 'd': 4}
>>>
Example 2: python dictionary multiple same keys
No, each key in a dictionary should be unique.
You can’t have two keys with the same value.
Attempting to use the same key again will just overwrite the previous value stored.
If a key needs to store multiple values,
then the value associated with the key should be a list or another dictionary.
Sourece: https://discuss.codecademy.com/t/can-a-dictionary-have-two-keys-of-the-same-value/351465