Logo

Programming-Idioms

History of Idiom 218 > diff from v16 to v17

Edit summary for version 17 by programming-idioms.org:
[Python] typo

Version 16

2020-05-02, 19:50:12

Version 17

2020-05-02, 19:50:26

Idiom #218 List intersection

Create list c containing all unique elements that are contained in both lists a and b.
c should not contain any duplicates, even if a and b do.
The order of c doesn't matter.

Idiom #218 List intersection

Create list c containing all unique elements that are contained in both lists a and b.
c should not contain any duplicates, even if a and b do.
The order of c doesn't matter.

Extra Keywords
intersect and conjunction
Extra Keywords
intersect and conjunction
Code
c = list(set(a).intersection(b))
Code
c = list(set(a).intersection(b))
Comments bubble
This avoid converting b into a set prior to the intersection.
Comments bubble
This avoids converting b into a set prior to the intersection.