In part of my program, I need to download the numeric program and output it as a list. Get a number from the input and then export it as a list between each comma.
Sample:
Entrance:1230
Output:[1,2,3,0]
In part of my program, I need to download the numeric program and output it as a list. Get a number from the input and then export it as a list between each comma.
Sample:
Entrance:1230
Output:[1,2,3,0]
Assuming input is used for string input, you can use list() to cast a string to a list of characters.
user_number = input("Input a number: ")
number_list = list(user_number)
a = 1234
print(list(map(int,list(str(a)))))
output:
[1, 2, 3, 4]
its a little messy so to break it down
a = 1234
a = str(a) # '1234'
a = list(a) # ['1', '2', '3', '4']
a = list(map(int, a)) # turns each element into an int