python string to list without split

Solutions on MaxInterview for python string to list without split by the best coders in the world

showing results for - "python string to list without split"
Ricardo
20 May 2019
1sentence = 'This is a sentence'
2split_value = []
3tmp = ''
4for c in sentence:
5    if c == ' ':
6        split_value.append(tmp)
7        tmp = ''
8    else:
9        tmp += c
10if tmp:
11    split_value.append(tmp)
12