Digitize number
Python, Math, List · Sep 15, 2020

Converts a number to a list of digits.
- Use
map()
combined withint
on the string representation ofn
and return a list from the result.
def digitize(n):
return list(map(int, str(n)))
digitize(123) # [1, 2, 3]