Digitize number

Python, Math, List · Sep 15, 2020

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]

More like this

  • Geometric progression

    Initializes a list containing the numbers in the specified range where start and end are inclusive and the ratio between two terms is step.

    Python, Math · Nov 2, 2020

  • Median

    Finds the median of a list of numbers.

    Python, Math · Nov 2, 2020

  • Greatest common divisor

    Calculates the greatest common divisor of a list of numbers.

    Python, Math · Sep 15, 2020