4 examples of 'how to find common elements in two lists python' in Python

Every line of 'how to find common elements in two lists python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
99def common(lst):
100 return set.intersection(*map(set, [i for i in lst]))
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

24def commonChars(self, A):
25 return list(reduce(Counter.__and__, map(Counter, A)).elements())
30def intersect(first_list, second_list):
31
32 return [x for x in first_list if x in second_list]
59def list_find(l, element):
60 for i, e in enumerate(l):
61 if e == element:
62 return i
63 return None

Related snippets