fir3net
PPS-Firenetbanner-780.5x190-30-03-17

Python - Check for Items across Sets

Within this example we will check if the same item exists across 2 sets. If so then a boolean is returned,

>>> s1 = set([1, 2, 3])
>>> s2 = set([3, 4, 5])
>>> bool(set(s1) & set(s2))
True

Tags: Python

About the Author

RDonato

R Donato

Rick Donato is the Founder and Chief Editor of Fir3net.com. He currently works as a Principal Network Security Engineer and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001