intersect(s1, s2) where s1 and s2 are lists representing sets, computes and return a list representing the intersection of the t | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

intersect(s1, s2) where s1 and s2 are lists representing sets, computes and return a list representing the intersection of the t

19th Sep 2016, 2:37 PM
Vinh Le
Vinh Le - avatar
2 Answers
+ 1
list(set(s1).intersection(set(s2)))
17th Sep 2016, 6:29 PM
Zen
Zen - avatar
+ 1
x=[] def intersect(s1, s2): for i in a: if i in b: x.append(i) return x
19th Sep 2016, 3:38 PM
Chandru Dhawan
Chandru Dhawan - avatar