30 seconds of python

  Back to Home

digitize

mathlistbeginner

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)))