Skip to content

Instantly share code, notes, and snippets.

@vikingviolinist
Created December 9, 2017 16:38
Show Gist options
  • Save vikingviolinist/170112187bf1833908acad8cca0f82fe to your computer and use it in GitHub Desktop.
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).
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