lst = [1, 2, 3, 5, 0, 0, 9, 45, 3, 0, 1, 7]
lst1 = []
summ = 0
for i, elem in enumerate(lst):
    if elem != 0:
        summ = summ + elem
else:
    if summ:
        lst1.append(summ)
lst1.append(elem)
summ = 0
if summ:
    lst1.append(summ)
Sum elements of a list between zeros in Python