I have data in the following format:
"22.926 g 47.377 g 73.510 g 131.567 g 322.744 g"
What I would like to do is to split it into a list such that value and units are grouped together, e.g.:
["22.926 g","47.377 g","73.510 g","131.567 g","322.744 g"]
Of course, in Python 2.7, I can do this the hard way:
result = []
tokens = "22.926 g 47.377 g 73.510 g 131.567 g 322.744 g".split()
for index,item in enumerate(tokens[::2]):
result.append(item+" "+tokens[index+1])
but I hoped that there is a slightly more elegant way for doing this?