Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save arjun921/23f37758dc75c980dbd2f6f0110bba8a to your computer and use it in GitHub Desktop.
Save arjun921/23f37758dc75c980dbd2f6f0110bba8a to your computer and use it in GitHub Desktop.
Take two lists and write a program that returns a list that contains only the elements that are common between the lists (without duplicates).
import random
a = random.sample(range(100), 5)
b = random.sample(range(100), 9)
print (a)
print(b)
new = set([i for i in a if i in b])
print (new)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment