Skip to content

Home

List without last element

Returns all the elements of a list except the last one.

def initial(lst):
  return lst[:-1]

initial([1, 2, 3]) # [1, 2]

More like this

Start typing a keyphrase to see matching snippets.