Python - Identity Operators
<Bitwise Operators Membership Operators >
Identity operators are used to checking if two operands or objects are the same.
Python supports two identity operators.
Operators | Meaning |
---|---|
is | This operator returns True only if both variables or operands refer to the same object otherwise returns False. |
is not | This operator returns True only if both variables or operands are not the same object Otherwise returns False. |
To get the identity of an object, we can use the id() function.
Python Identity Operators Example
>> x=10
>> y=10
>> z='welcome'
>> print(x is y)
True
>> print(x is z)
False
>> print(x is not z)
True
>> print(y is not z)
True
>> print(y is x)
True
<Bitwise Operators Membership Operators >