Contains of HashSet in Python

In Java we have HashSet<Integer>, I need similar structure in Python to use contains like below:

A = [1, 2, 3]
S = set()
S.add(2)
for x in A:
    if S.contains(x):
        print "Example"

Could you please help?

Leave a Comment