is
operator : I know that is
operator checks whether both the operands refer to the same object or not.
a = "Hello World!"
b = a
print(a == b)
print(a is b)
output
True
True
Now, I will use input()
to get input from the user.
c = "Python"
d = input("Enter string : ")
print(c == d)
output
Enter string : Python
True
but if I will try to print
print(c is d)
output
False
I don't know why it is happening with input()
.
If I directly assign one variable to another variable, is
operator is working fine but if I will get same value from input()
, is
opeartor will be given False
.
I want to know that, why it is not referring the same object when we use input()
.