a = [0, 0, 0, 0, 0, 0, 10, 15, 16, 12, 11, 9, 10, 0, 0, 0, 0, 0, 6, 9, 3, 7,
    5, 4, 0, 0, 0, 0, 0, 0, 4, 3, 9, 7, 1]
previous = 0
count = 0
for c in a:
    if previous == 0 and c != 0:
        count += 1
previous = c
print(count)
Count number of clusters of non-zero values in Python?