Files
30-seconds-of-code/snippets/last.md
Angelos Chalaris 7ebb059255 Add last snippet
2019-08-20 15:11:47 +03:00

213 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