Last active
August 29, 2015 14:23
-
-
Save jonathanpike/3343a66c3d57b3538bec to your computer and use it in GitHub Desktop.
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
# from http://www.practicepython.org/exercise/2014/04/10/10-list-overlap-comprehensions.html | |
import random | |
# a = random.sample(range(1,1000), 20) | |
# b = random.sample(range(1,1000), 30) | |
a = [1, 1, 3, 5, 6, 7, 8, 10] | |
b = [1, 1, 6, 7, 10, 14, 17, 18] | |
a.sort() | |
b.sort() | |
print a | |
print b | |
new_list = [x for x in a and b if x in a and x in b] | |
print new_list | |
result = [] | |
for i in new_list: | |
if i in result: | |
pass | |
else: | |
result.append(i) | |
print result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment