Python – Convert a number to a list of integers

integerlistpython

How do I write the magic function below?

>>> num = 123
>>> lst = magic(num)
>>>
>>> print lst, type(lst)
[1, 2, 3], <type 'list'>

Best Solution

You mean this?

num = 1234
lst = [int(i) for i in str(num)]