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))

Tags: Python

About the Author


R Donato

Rick Donato is the Founder and Chief Editor of He currently works as an SDN/NFV Solutions Architect and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001