0

Help me please!

Why "is" evaluates to True in the first case and to False in the second? First case: a = 247 b = 247 print((a is b) == (a == b)) >>> True Second case: a =[2,3,4] b =[2,3,4] print(a is b) >>> False Also please let me know where can I found more on this "is". Thanks in advance!

18th Jun 2019, 7:42 PM
Dragos
Dragos - avatar
2 Answers
+ 3
The "is" operator checks if 2 values refer to the same object, while == checks if their values are equal. When comparing object, it returns false even if they have the same values. It only returns true if you specifically assign it go
18th Jun 2019, 7:50 PM
Airree
Airree - avatar
0
Airree thanks! In the meantime I found this topic: https://stackoverflow.com/questions/132988/is-there-a-difference-between-and-is I feel more confortable now.
18th Jun 2019, 8:24 PM
Dragos
Dragos - avatar