Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren+ 1
How to intersect two lists
1 Antwort
+ 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]