New course! Every coder should learn Generative AI!
Try a free lesson+ 4
membership operators are used to validate the membership of a value.
Identity operators are used to verify if two variables point to the same memory location or not.
Example of membership operator is "in" and "not in"
"ram" in ["ram","shyam"] #True
"o" in "Sololearn" #True
Example of identity operator is "is" and "is not"
a=[1,2,3]
b=a
c=[1,2,3]
a is b #True
c is a #False. Mutables can have same content in different memory location
d="sololearn"
e="sololearn"
d is e #True. Immutable having same content are in same memory location