Add digitize snippet

This commit is contained in:
Angelos Chalaris
2019-08-20 13:00:27 +03:00
parent 613a56cc86
commit 852007e276

17
snippets/digitize.md Normal file
View File

@ -0,0 +1,17 @@
---
title: digitize
tags: math,list,beginner
---
Converts a number to an array of digits.
Use `map()` combined with `int` on the string representation of `n` and return a list from the result.
```py
def digitize(n):
return list(map(int, str(n)))
```
```py
digitize(123) # [1, 2, 3]
```