Turn a single number into single digits Python [duplicate]


I want to make a number , for example 43365644 into single numbers [4,3,3....,4,4]

and append it on a list


Answers:


This can be done quite easily if you:

  1. Use str to convert the number into a string so that you can iterate over it.

  2. Use a list comprehension to split the string into individual digits.

  3. Use int to convert the digits back into integers.

Below is a demonstration:

>>> n = 43365644
>>> [int(d) for d in str(n)]
[4, 3, 3, 6, 5, 6, 4, 4]
>>>