SyntaxFix
Write A Post
Hire A Developer
Questions
set intersection and dict comprehension can be used here
set intersection
dict comprehension
# the dictionary d = {1:2, 3:4, 5:6, 7:8} # the subset of keys I'm interested in l = (1,5) >>>{key:d[key] for key in set(l) & set(d)} {1: 2, 5: 6}