Python Check if Item Exists in a Set
Check if Item Exists in a Set
To determine if a specified item is present in a set use the in
keyword:
Example
Check if "apple" is present in the set:
thisset = {"apple", "banana", "cherry"}
if "apple" in thisset:
print("Yes, 'apple' is in this set")
Try it Yourself »