30 seconds of python

  Back to Home

all_equal

listbeginner

Check if all elements in a list are equal.

Use [1:] and [:-1] to compare all the values in the given list.

def all_equal(lst):
  return lst[1:] == lst[:-1]