Nov-26-2020, 04:22 PM
Hello
I have this list
b = [0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,01,0,1,0,1,0,1,0,1,0,1,0,1]
And I want to sum every 10 element in the list after that I want to divide first 10 element with first sum, devide second then element with the second time...
I can find the sum every 10 element with this code
For instance for the example,sum of first 10 element is 5 and so the element should change like that:
b = [0,0.2,0,0.2,0,0.2,0,0.2,0,0.2010101010101010101010101010101] and so on..
Thanks for helps
I have this list
b = [0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,01,0,1,0,1,0,1,0,1,0,1,0,1]
And I want to sum every 10 element in the list after that I want to divide first 10 element with first sum, devide second then element with the second time...
I can find the sum every 10 element with this code
b= [sum(randomlist[i:i+10]) for i in range(0, len(randomlist), 10)]But after that I really don't know how can I divide them
For instance for the example,sum of first 10 element is 5 and so the element should change like that:
b = [0,0.2,0,0.2,0,0.2,0,0.2,0,0.2010101010101010101010101010101] and so on..
Thanks for helps