I have a list like this:
['PHE', '45', 'HIS', '46', 'HIS', '46', 'HIS', '46', 'HIS', '46', 'HIS', '46']
I want it to turn into
['PHE 45', 'HIS '46', 'HIS '46'] # it goes on like that
how can I merge consecutive list elements to eachother?
I have a list like this:
['PHE', '45', 'HIS', '46', 'HIS', '46', 'HIS', '46', 'HIS', '46', 'HIS', '46']
I want it to turn into
['PHE 45', 'HIS '46', 'HIS '46'] # it goes on like that
how can I merge consecutive list elements to eachother?
List comprehension for instance..
out = [str(L1[i]) + " " + str(L1[i+1]) for i in range(0, len(L1)//2, 2)]
# Out[15]: ['PHE 45', 'HIS 46', 'HIS 46']