Files
30-seconds-of-code/snippets/python/s/digitize.md
2023-05-07 16:07:29 +03:00

387 B

title, type, language, tags, cover, dateModified
title type language tags cover dateModified
Digitize number snippet python
math
list
laptop-with-code 2020-09-15T16:13:06+03:00

Converts a number to a list 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]