I want to be able to add values to a list. For example, I have these two list:
alist = [1,3,5,7,9]
blist = [0]
I want to insert a value to blist that is the value of alist with all values prior to it within alist. For example, blist would be the following:
blist = [0,1,4,9,25]
Since 1 is the first value in alist it stays the same, then I do 1+3 =4, 1+3+5 =9, etc.
However, I'm very confused about how I need to go about implementing this. I have the following piece of code:
list1 = [1,2,3,4,5]
list2 = [0]
x = 0
while x < len(list1):
blist.append(alist[0])
This would append the first value at position 0 to list2 and would make list2 = [0,1]. However, I don't understand how to go about in order to add the values the way I need to.
blist = [o]toblist = [0]because I was pretty sure you didn't meanblist = ['o']. FYIblist = [o]is a NameErrornumpy.cumsum