Files
30-seconds-of-code/snippets/last.md
Isabelle Viktoria Maciohsek 0a2f7993f7 Update snippet descriptions
2020-11-02 19:28:05 +02:00

215 B

title, tags
title tags
last list,beginner

Returns the last element in a list.

  • Use lst[-1] to return the last element of the passed list.
def last(lst):
  return lst[-1]
last([1, 2, 3]) # 3