ReferenceSet methods
set.intersection()
Only what is in both sets.
Signature
a.intersection(b) or a & bParameters
| Name | Means |
|---|---|
b | another set |
Returns
A new set.
Example
Python
a = {1, 2, 3}
b = {2, 3, 4}
print(sorted(a & b))Output
[2, 3]
Basics
Strings
Collections
Functions
Classes and objects
Modules and the standard library
Files and errors
Beyond the basics
ReferenceSet methods
Only what is in both sets.
a.intersection(b) or a & b| Name | Means |
|---|---|
b | another set |
A new set.
a = {1, 2, 3}
b = {2, 3, 4}
print(sorted(a & b))Output
[2, 3]