I am making up a code in Python 3.7 in which I need to split an array in chunks.
The array is something similar to the following one:
['1.60500002', '1.61500001', '1.625', '1.63499999','NO',
'1.73500001','1.745', 'NO','2.04500008', '2.05499983']
I am interested to create n different slices (3 in this case) everytime the string 'NO' occurs. Then the output array should be something like:
[['1.60500002', '1.61500001', '1.625', '1.63499999'],
['1.73500001', '1.745'],
['2.04500008', '2.05499983']]
Could someone help me?
[i.strip().split(' ') for i in ' '.join(_list).split('NO') if len(i) > 0 ]