a = [-2, -2, 0, 0, 0, 0, 0]
b = [-2, 20, -1, 0, 3, 0, 0]

def index_of_last_nonzero(lst):
    for i, value in enumerate(reversed(lst)):
        if value != 0:
            return len(lst) - i - 1
return -1
print(index_of_last_nonzero(lst=a))
print(index_of_last_nonzero(lst=b))
return index of last non-zero element in list