code: def accumulate(iterable, func=operator.add):
      
      it = iter(iterable)
      total = next(it)
      yield total
      for element in it:
          total = func(total, element)
          yield total
docs: Cumulative calculations. (Summation, by default.)
      Via: https://docs.python.org/3/library/itertools.html#itertools.accumulate