Membership operator in Python

Membership operator in Python

a = 10
b = 20
list = [20,40,60]

if(a in list):
    print("{0} is present in list".format(a))
else:
    print("{0} is not present in list".format(a))

if(b in list):
    print("{0} is present in list".format(b))
else:
    print("{0} is not present in list".format(b))

Output :

Leave a Comment