check if set contains element python code example
Example 1: checking if a value is in a set python
thisset = {"apple", "banana", "cherry"}
if "apple" in thisset:
print("Yes, 'apple' is in this set")
Example 2: python set contains
a_set = {1, 2, 3}
one_in_a_set = 1 in a_set # True