How do I write the magic function below?
magic
>>> num = 123 >>> lst = magic(num) >>> >>> print lst, type(lst) [1,
You can try this:
def convert_to_list(number): return list(map(lambda x: int(x), str(number))) convert_to_list(1245)