Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • to allow empty input list: set(*input_list[:1]).intersection(*input_list[1:]). Iterator version (it = iter(input_list)): reduce(set.intersection, it, set(next(it, []))). Both version doesn't require to convert all input lists to set. The latter is more memory efficient. Commented Dec 5, 2012 at 6:41
  • Use from functools import reduce to use it in Python 3. Or better yet, use an explicit for loop. Commented Aug 2, 2016 at 8:51