+ 5
Every time you define an object in python you are creating new object with new identity, check this: class Ob: pass a = Ob() b = Ob() >>> a is b False But python has special case with integers smaller than 256, it caches (integer objects) in range (-5, 256) for perfomane reasons, look at this: a = 5 b = 5 >>> a is b True a = 10 b = 5 >>> a is b*2 True a = 500 b = 250 >>> a is b*2 False Id varies with strings that has a length higher than 20 charecter: a = "xxxx" >>> a is "x"*4 True a = "xxxx"*5 >>> a is "x"*20 True a = "xxxxx"*5 >>> a is "x"*25 False In your case the variable "a" is an (input object) and "b" is another (input object) that has new identity, so id of variable "a" != id of variable "b", But one byte of the input has special case? a = input("") b = input("") >>> a = "x" >>> b = "x" >>> a is b True >>> a = "xx" >>> b = "xx" >>> a is b False!
5th Mar 2018, 3:13 AM
ƒred
ƒred - avatar
+ 9
it doesn't vary if they're the same.
5th Mar 2018, 1:04 AM
Ahri Fox
Ahri Fox - avatar