How can I intersect values of a dictionary in python?

Question:

For example this is a dictionary

dic={3: [2, 7, 8], 1: [7]}

I want a list like this [7]

Asked By: Image Privacy

||

Answers:

First, get all the values using .values, then convert them to set, and get the intersection of them:

set.intersection(*list(map(set, dic.values())))
Answered By: anishtain4
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.