Skip to content

Commit 6a8c455

Browse files
authored
Create Exercise-10-List-Overlap-Comprehensions.py
1 parent 1b48b70 commit 6a8c455

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'''
2+
Exercise 10: List Overlap Comprehensions
3+
4+
This week’s exercise is going to be revisiting an old exercise (see Exercise 5).
5+
And this solution is a copy of exercise 5.
6+
7+
Extras:
8+
9+
Randomly generate two lists to test this
10+
11+
'''
12+
import random
13+
# Solution
14+
# a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
15+
# b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
16+
a = [int(10 * random.random()) for i in range(20)]
17+
b = [int(10 * random.random()) for i in range(15)]
18+
print("List 1: ", a)
19+
print("List 2: ", b)
20+
print("Overlap: ", list(set(a).intersection(b)))

0 commit comments

Comments
 (0)