在代码中,我们需要Add average of running total to running total until the end of the year”翻译成“将运行总计数的平均值加到运行总计数中,直到年底”。
代码示例:
def running_total_average(lst): running_total = 0 for num in lst: running_total += num running_total += running_total/(len(lst)-lst.index(num)) return running_total
lst = [1, 2, 3, 4, 5] print(running_total_average(lst)) # 输出21.6667