I am new to python and i was wondering how i could create a list of numbers in python as such
number = 123456
list_to_be_created = [1,2,3,4,5,6]
Thank you in advance
>>> list(range(1, 7))
[1, 2, 3, 4, 5, 6]
If you literally have the number 123456 (i.e. the int
value for one hundred twenty three thousand four hundred fifty six) and you want to turn it into a list of its digits, you might do:
>>> number = 123456
>>> list_to_be_created = list(map(int, str(number)))
>>> list_to_be_created
[1, 2, 3, 4, 5, 6]