Files
30-seconds-of-code/snippets/last.md
2020-09-15 16:25:15 +03:00

18 lines
215 B
Markdown

---
title: last
tags: list,beginner
---
Returns the last element in a list.
- use `lst[-1]` to return the last element of the passed list.
```py
def last(lst):
return lst[-1]
```
```py
last([1, 2, 3]) # 3
```