Files
30-seconds-of-code/snippets/tail.md
Angelos Chalaris 47b718dd54 Remove semicolons
Remove semicolon in head
Remove semicolon in initial
Remove semicolons in tail
2020-01-03 13:08:15 +02:00

19 lines
308 B
Markdown

---
title: tail
tags: 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.
```py
def tail(lst):
return lst[1:] if len(lst) > 1 else lst
```
```py
tail([1, 2, 3]) # [2,3]
tail([1]) # [1]
```