Created
December 9, 2017 16:38
-
-
Save vikingviolinist/170112187bf1833908acad8cca0f82fe to your computer and use it in GitHub Desktop.
Randomly generate 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 | |
x = random.sample(range(1, 100), 10) | |
y = random.sample(range(1, 100), 13) | |
print(x) | |
print(y) | |
print([i for i in set(x) if i in set(y)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment