I want to split a python string line = '1 -1 2 3 -1 4'
so that my output is a python list['1','2','3','4']
. I tried solution given here and here. However, some strange output is coming. My code:
line = '1 -1 2 3 -1 4'
import re
t=re.split("-1| ", line)
output:
['1', '', '', '2', '3', '', '', '4']
Any help is appreciated!