Better way to check if all lists in a list are the same length?

Viewed 15855

Currently running with:

l1 = [i for i in range(0,10)]
l2 = [i for i in range(0,10)]
l3 = [i for i in range(0,10)]
lists = [l1, l2, l3]
length = len(lists[0])
for l in lists:
    if length != len(l):
        raise ValueErrorr('not all lists have same length!')

Is there a prettier way to test for this than a for loop? Is there a faster/better way which isn't O(n) ?

5 Answers
Related