Operator | Description | Example |
in | Returns True if a sequence with the specified value is present in the object | x in y |
not in | Returns True if a sequence with the specified value is not present in the object | x not in y |
x = 24
y = 20
list = [15, 20, 35, 40, 50]
if (x not in list):
print("x is NOT present in given list")
else:
print("x is present in given list")
if (y in list):
print("y is present in given list")
else:
print("y is NOT present in given list")
Output
x is NOT present in the given list
y is present in the given list
Keywords:
membership operators in python with an example,
Python Membership Operators,
What is membership operator explain with example?,
What are membership operators in the list in Python?,
Python Membership and Identity Operators,
What are membership operators in Python,
What are membership operators in Python?,