Files
30-seconds-of-code/snippets/digitize.md
Angelos Chalaris 852007e276 Add digitize snippet
2019-08-20 13:00:27 +03:00

292 B

title, tags
title tags
digitize 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.

def digitize(n):
  return list(map(int, str(n)))
digitize(123) # [1, 2, 3]