我必须将列表中的相邻数字相加,如下所示:
ls = [5, -2, -2, 2, -4, -2 ,-2, 7, 3, 1]
输出应该是: [5, -4, 2, -8, 11]
[5, -4, 2, -8, 11]
python sum list
list ×1
python ×1
sum ×1