There are two special operators in Python. Those are Identical & Membership. These operators look like English words. Here are the differences and how to use them.
Identical Operators
- IS
- IS NOT
Let me show how to use these two operators. Here is an example that exhibit how to use those.
Python logic for IS NOT
a = 'java'
b = 'php'
print ('Output is true because a and b values not matches', a is not b)
Here the identical operators give Boolean values. That means either True/False. When you run the above logic, you will get True since both a and b are not the same.

Python logic for IS
a1 = 'java'
b1 = 'java'
print ('Output is True because a1 and b1 values matches', a1 is b1)
Here the output will be True since both a1 and b1 are the same. So we will get True.

Membership operators
Membership operators are two types. Those are in & not in. Here is a list of membership operators.
- IN
- NOT IN
Python logic for IN
c = int(input("Enter the value"))
print ("The value of c is: " + format(c))
lst1 = [12,3,5,6,9]
if c in lst1:
print('c value is available in the list', c in lst1)
else:
print('c value is not available in the list', c in lst1)
Here the output will be True since the entered value is in the list. Here is output.

Python logic for NOT IN
c = int(input("Enter the value"))
print ("The value of c is: " + format(c))
lst1 = [12,3,5,6,9]
if c in lst1:
print('c value is available in the list', c in lst1)
else:
print('c value is not available in the list', c in lst1)
Here the output will be False since the value your entered is not in the list. See the output.

So you got to know the differences between identical and membership operators in python.
Related posts
You must be logged in to post a comment.