list = [3,0,1,-2] total = 0 for i in list: total = total + i print(lista)
list = [3,0,1,-2] for i in range(1, len(list)): list[i] += list[i - 1] print(list)
python atest.py [3, 3, 4, 2] Python test result: 0
list = [3,0,1,-2] total = 0 # you may need to create lista here for i in list: total = total + i # add total to lista here print(lista)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)