I’ve hit a brick wall with this attempted code implementation. I am basically trying to search through a large list of sublists and find any sublist greater than 10 in length. I then want to split the sublist in half and add the first element of the list to the sublist that has been split.
lst0 = [['H2:blah', '1', '3', '4','5'], ['H2:blahhh', '12','13','14','15','16','17','18','19','20'],['H2:blaher', '22','23','24','25','26'], ['H2:blahhh', '99','98','97','97','12','13','14','15','16','17','18','19','20']]
for z in lst0:
if len(z) > 10:
print((z))
['H2:blahhh', '99', '98', '97', '97', '12', '13', '14', '15', '16', '17', '18', '19', '20']
I would then need to split the sub list like this…
['H2:blahhh', '99', '98', '97', '97', '12', '13']
['H2:blahhh', '14', '15', '16', '17', '18', '19', '20']
and then put it all back together in the main list…
lst0 = [['H2:blah', '1', '3', '4','5'], ['H2:blahhh', '12','13','14','15','16','17','18','19','20'],['H2:blaher', '22','23','24','25','26'], ['H2:blahhh', '99', '98', '97', '97', '12', '13'],
['H2:blahhh', '14', '15', '16', '17', '18', '19', '20'
]
Any pointers would be great. I try to find the sublist number but it’s not so clear how do this.