Lostsoul Lostsoul - 1 year ago 72
Python Question

Is there a way to see if two lists are the exact same without looping in python?

Say I have:

a = [1, 2, 3]
b = [1, 2, 3]

is there a way to test the lists to see if they are the same, without having to loop through each entry?

Here's what I was thinking..I know to check if two variables are the same I could use:


but it doesn't work because the ID's are different so is there some type of checksum or way that python stores values of the table so I can simply compare two variables?

Answer Source

Doesn't == work?

>>> a = [1, 2, 3]
>>> b = [1, 2, 3]
>>> a == b
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download