Sep-27-2018, 09:07 AM
(This post was last modified: Sep-27-2018, 09:31 AM by juniorcoder.)
Hello Folks ,
I need a small help . Here is my code:
[6, 7, 6, 9, 8]
[[8, 8, 8, 8, 6], [35, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
[[8, 8, 8, 8, 6], [42, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
[[8, 8, 8, 8, 6], [48, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
[[8, 8, 8, 8, 6], [57, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
[[8, 8, 8, 8, 6], [65, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
It always sum the random value on the new list cumulatively, but what I want is , to sum the random values always to the first value of original list which is 29 . So I should obtain
[[8, 8, 8, 8, 6], [35, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
[[8, 8, 8, 8, 6], [36, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
[[8, 8, 8, 8, 6], [35, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
[[8, 8, 8, 8, 6], [38, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
[[8, 8, 8, 8, 6], [37, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
and when I sum the all the elemenets of above lists ,I should choose the list which has the least sum among all these 5 arrays ? Let's say the sum of the first array is 100, second is 85, third is 40, fourth is 98, fifth is 135, I should obtain as output second third array whc has least sum (40) how can I do that ?
thank you so much
I need a small help . Here is my code:
from random import randint
X=[[8, 8, 8, 8, 6], [29, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
SaveX=X
K=[]
for t in range(5):
a=randint(5,10)
K.append(a)
print(K)
for a in range(5):
X[1][0]=X[1][0]+K[a]
print(X)The output is like [6, 7, 6, 9, 8]
[[8, 8, 8, 8, 6], [35, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
[[8, 8, 8, 8, 6], [42, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
[[8, 8, 8, 8, 6], [48, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
[[8, 8, 8, 8, 6], [57, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
[[8, 8, 8, 8, 6], [65, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
It always sum the random value on the new list cumulatively, but what I want is , to sum the random values always to the first value of original list which is 29 . So I should obtain
[[8, 8, 8, 8, 6], [35, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
[[8, 8, 8, 8, 6], [36, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
[[8, 8, 8, 8, 6], [35, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
[[8, 8, 8, 8, 6], [38, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
[[8, 8, 8, 8, 6], [37, 27, 27, 27, 27], [9, 9, 9, 9, 10]]
and when I sum the all the elemenets of above lists ,I should choose the list which has the least sum among all these 5 arrays ? Let's say the sum of the first array is 100, second is 85, third is 40, fourth is 98, fifth is 135, I should obtain as output second third array whc has least sum (40) how can I do that ?
thank you so much
