from itertools import starmap, accumulate def moving_everage(nums): return starmap(lambda a, b: b/a, enumerate(accumulate(nums), 1)) nums = [-3, 2, 5, 7, 2, 1] print(list(moving_everage(nums))) # [-3.0, -0.5, 1.3333333333333333, 2.75, 2.6, 2.3333333333333335]




가독성은 안 좋게 되지만, 작성하는 입장에서는 손이 엄청 덜 가는....... 이동 평균을 이보다 짧게 작성할 수 있을지