Reorganize snippets

This commit is contained in:
Angelos Chalaris
2023-05-03 21:19:02 +03:00
parent 7511813169
commit 5c913d20bd
1240 changed files with 992 additions and 0 deletions

23
python/s/sample.md Normal file
View File

@ -0,0 +1,23 @@
---
title: Random element in list
type: snippet
language: python
tags: [list,random]
cover: walking-on-top
dateModified: 2020-10-28T11:45:34+02:00
---
Returns a random element from a list.
- Use `random.choice()` to get a random element from `lst`.
```py
from random import choice
def sample(lst):
return choice(lst)
```
```py
sample([3, 7, 9, 11]) # 9
```