In a = [1, 2]
and b = [1, 2]
, a == b
is True and a is b
is False but could someone please explain how a == [1, 2]
returns True
Asked
Active
Viewed 31 times
0

motrait
- 9
- 2
-
2Does this answer your question? [Is there a difference between "==" and "is"?](https://stackoverflow.com/questions/132988/is-there-a-difference-between-and-is) – Boendal Jan 02 '20 at 10:06
-
1[Lists are equal if elements at the same index are equal](https://stackoverflow.com/a/36420107/5168011) – Guy Jan 02 '20 at 10:07
-
Try the printing the ```id``` of both the variables. You will get your answer for ```is``` and ```==``` only checks the elements in the list – Vaibhav Jadhav Jan 02 '20 at 10:10
-
@Guy many thanks. i get it – motrait Jan 02 '20 at 10:18