Files
30-seconds-of-code/snippets/reverse.md
2020-10-06 19:02:30 +03:00

19 lines
256 B
Markdown

---
title: reverse
tags: list,string,beginner
---
Reverses a list or a string.
- Use slice notation to reverse the list or string.
```py
def reverse(itr):
return itr[::-1]
```
```py
reverse([1, 2, 3]) # [3, 2, 1]
reverse("snippet") # "teppins"
```