Python Operators

Identity Operator


c = [1, 2, 3]

a = [1, 2, 3]

b = a



# equality operator

print('a == c = ', (a==c)) # True



# identity operator

print('a is c = ', (a is c)) # False

print('a is not c = ', (a is not c)) # True



print('a is b = ', (a is b)) # True

print('a is not b = ', (a is not b)) # False

Membership Operator


a = 'Python'

b = 'Learn Python'



# membership operator

print('a in b = ', (a in b)) # True

print('a not in b = ', (a not in b)) # False



print('b in a = ', (b in a)) # False

print('b not in a = ', (b not in a)) # True

Leave a Comment