[Solved] append all Integers of an integer in a list in python using recursive function [closed]


Try this?

def numberToList(number):

    # base case
    if number == 0:
        return []

    # recurse
    return numberToList(number / 10) + [ number % 10 ]

Run it like this:

>>> numberToList(1234)
[4, 3, 2, 1]

1

solved append all Integers of an integer in a list in python using recursive function [closed]