728x90
반응형
>>> a = [1,2,3,4,5]
>>> b = [1,3,5,6]
>>> list(set(a) & set(b))
[1, 3, 5]
https://stackoverflow.com/questions/3697432/how-to-find-list-intersection
How to find list intersection?
a = [1,2,3,4,5] b = [1,3,5,6] c = a and b print c actual output: [1,3,5,6] expected output: [1,3,5] How can we achieve a boolean AND operation (list intersection) on two lists?
stackoverflow.com
728x90
반응형
'공부 (@Deprecated)' 카테고리의 다른 글
| [Python] RuntimeError: 'cryptography' package is required for sha256_password or caching_sha2_password auth methods (0) | 2021.08.13 |
|---|---|
| [MySQL] TRUNCATE TABLE {table} (0) | 2021.08.13 |
| [Python] pylint black (black -m {path}) (0) | 2021.07.25 |
| [Python] string format range text (0) | 2021.07.25 |
| [Linux] overwrite symbolic link (0) | 2021.07.25 |