In Python, we can check if an element is present in a set using the "in" operator. This operator returns a boolean value of "True" if the specified element is present in the given set, else "False".
Here's an example of how to check if an element is in a set:
main.py98 chars4 lines
In the above example, we are checking whether the elements '3' and '6' are present in the set 'my_set'. The first print statement returns "True" as '3' is present in the set, whereas the second print statement returns "False" as '6' is not present in the set.
gistlibby LogSnag