Files
30-seconds-of-code/snippets/tail.md
2019-08-20 14:08:52 +03:00

310 B

title, tags
title tags
tail list,beginner

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

Return lst[1:] if the list's length is more than 1, otherwise, return the whole list.

def tail(lst):
  return lst[1:] if len(lst) > 1 else lst
tail([1, 2, 3]); # [2,3]
tail([1]); # [1]