+ 1

How to intersect two lists

23rd Dec 2019, 8:06 AM
PRATHIKSHA.V
PRATHIKSHA.V - avatar
2 Respostas
+ 5
As a comprehension is also a nice way to do it: lst1 = [1,2,3,4] lst2 = [1,4,7,2] print([i for i in lst1 if i in lst2]) # output: [1,2,4]
23rd Dec 2019, 8:27 AM
Lothar
Lothar - avatar