Created
October 13, 2021 15:27
-
-
Save janbenetka/2c164710a3e59c11f73b08feb9f7b9d4 to your computer and use it in GitHub Desktop.
[Filter dictionary by keys] #python #dictionary #lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | |
keys_to_remove = ("c","d") | |
updated_dict = dict_filter(large_dict, keys_to_remove) | |
print(updated_dict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment