Hi @Hajnalka_Toth,
Yes, all elements in the two lists are the same plus in the same order, but why does it return False
?. Well, you might have noticed that there’s a is keyword in the print()
statement. And what that does is “matches the references (not the values/elements) of those two lists”!
list1
and list2
are created on different memory locations, which is why the print(list1 is list2)
returns False
, which should be the expected output.
Note: If you change list1 is list2
to list1 == list2
, then you would get a True
value because the “==” operator compares the values of these two lists.
Thank you so much, and hope this helps.