如何在列表中找到数字的累积和?
time_interval = [4, 6, 12]
我想总结一下这些数字[4, 4+6, 4+6+12]为了得到名单t = [4, 10, 22].
[4, 4+6, 4+6+12]
t = [4, 10, 22]
我尝试了以下几点:
for i in time_interval: t1 = time_interval[0] t2 = time_interval[1] + t1 t3 = time_interval[2] + t2 print(t1, t2, t3)4 10 224 10 224 10 22
婷婷同学_
开心每一天1111
相关分类