Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

README.md

Find Common Elements in Lists

Solution 😎

l1 = [4, 5, 34, 9]
l2 = [4, 5, 80, 10]
result = list(set(l1) & set(l2))

print('first list:', l1)
print('second list:', l2)
print('result:', result)

This code takes two lists, and first converts them to sets using the set() function. Then, it uses the & operator to find the intersection of the two sets, and converts the resulting set back to a list using the list() function.

Video Solution 📹

Find Common Elements in Lists

<iframe width="560" height="315" src="https://www.youtube.com/embed/8JaRKMnMjXA" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>