Nest all content into snippets

This commit is contained in:
Angelos Chalaris
2023-05-07 16:07:29 +03:00
parent 2ecadbada9
commit 6a45d2ec07
1240 changed files with 0 additions and 0 deletions

23
snippets/python/s/tail.md Normal file
View File

@ -0,0 +1,23 @@
---
title: List tail
type: snippet
language: python
tags: [list]
cover: meteora
dateModified: 2020-11-02T19:28:35+02:00
---
Returns all elements in a list except for the first one.
- Use slice notation to return the last element 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]
```