To get the intersection of two sets in python, you can use the intersection()
method or the &
operator.
Here's an example using the intersection()
method:
main.py130 chars5 lines
And here's an example using the &
operator:
main.py118 chars5 lines
In both cases, the intersection_set
variable will contain the intersection of both sets (i.e., the elements that are present in both of them).
gistlibby LogSnag