The Most Pythonic Way to Check if Two Ordered Lists Are Identical

The most Pythonic way to check if two ordered lists l1 and l2 are identical, is to use the l1 == l2 operator for element-wise comparison. If all elements are equal and the length of the lists are the same, the return value is True.

Problem: Given are two lists l1 and l2. You want to perform Boolean Comparison: Compare the lists element-wise and return True if your comparison metric returns True for all pairs of elements, and otherwise False.


l1 = [1, 2, 3, 4, 5]
l2 = [1, 2, 3]
# compare(l1, l2) –> False

l1 = [1, 2, 3, 4, 5]

Continue reading the original article