I was thinking about my code
and I think (after debbuging it) it doesnt work good.
In my task I have this short list of numbers:
numbers = [
2892921,
1939929,
2929202,
1758690,
I have to add to each other my numbers in this way:
1 2 3 ... 2892921 = sum, and my
for loop
should go next: 1 2 3 ... 1939929 = sum2 ect.
I've written this code. Please give me a sign where can I repeair it to work good?
def sum(__self__):
suma = 0
for i, val in enumerate(numbers):
i = 1
n = val
for j in range(1, n):
suma = j
print(suma)
return suma
CodePudding user response:
numbers = [
2892921,
1939929,
2929202,
1758690
]
def sum_n(number):
return sum(range(1, number 1))
sums = [sum_n(number) for number in numbers]
print(sums)
print(sum(sums))