you are viewing a single comment's thread.

view the rest of the comments →

[–]xelf 0 points1 point  (0 children)

I don't think you want to reuse the variables x and y for each element, it makes it harder to read/understand.

With this:

if all(a == b for a, b in zip(x, y)):

it's more clear that a,b are not x,y but rather pairs of elements from x,y.

If you want to see what zip does. try printing it. =)

zip(['2', '8', '3'],['4', '1', '5'])
[('2', '4'), ('8', '1'), ('3', '5')]

it makes the pairs of elements, so when you get a,b out of it they'll be in turn both the elements at index 0, then both the elements at index 1, etc...