Created
December 18, 2016 04:43
-
-
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).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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