Skip to content

Home

List tail

Returns all elements in a list except for the first one.

def tail(lst):
  return lst[1:] if len(lst) > 1 else lst

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

More like this

Start typing a keyphrase to see matching snippets.