0
[1, 2, 3]?
a=[1,2,3] b=[1,2,3] print(a is b) Solution: False Why is it false? 123 is the sams as 123? Is it converted from a list to a string? Any help is appreciated.
3 odpowiedzi
+ 5
The is keyword in Python checks to see if two variables are the same object and will return true if they do. This, however, means that it will return false if you compare 2 different objects even if they have the same value. In your code, although the variables a and b have the same value, they are not by any means the same object, which is why it is returning false.
+ 1
Thanks for your clear answer Faisal:)
0
Thank you TT!