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
Rick Donato

Want to become a programming expert?

Here is our hand-picked selection of the best courses you can find online:
Python Zero to Hero course
Python Pro Bootcamp
Bash Scripting and Shell Programming course
Automate with Shell Scripting course
The Complete Web Development Bootcamp course
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial