Given a list like:
A = [18, 7, 0, 0, 0, 9, 12, 0, 0, 11, 2, 3, 3, 0, 0, 7, 8]
is there a simple way to create subarrays, with those elements that are separated by zeros (or at least by NaNs)? I mean, like:
A1 = [18, 7]
A2 = [9, 12]
A3 = [11, 2, 3, 3]
A4 = [7, 8]
I've written:
q=0
for i in range(0,len(A)):
if A[i]-A[i-1] < 1:
q=q+1
to retrieve the number of zeros-packets present in the list. But I need to populate subarrays, as long as I encounter them through the list... maybe something with the split
function? Thank you in advance.