split a string input as a int to list python code example
Example 1: split numbers python
num = 12345
>>> [int(i) for i in str(num)]
[1, 2, 3, 4, 5]
Example 2: python string to list without split
sentence = 'This is a sentence'
split_value = []
tmp = ''
for c in sentence:
if c == ' ':
split_value.append(tmp)
tmp = ''
else:
tmp += c
if tmp:
split_value.append(tmp)