0
Why it doesnt work? exercise: Find the sum of all the multiples of 3 or 5 below 1000.
y = [] x = [] a = 0 result = 0 for i in range(1001): x.append(i) while a < 1001: if x[a] % 5 == 0 or x[a] % 3 == 0: y.append(x[a]) a += 1 a = 0 while a < len(y) or y == len(y): result = result + y[a] a += 1 print (result)
4 ответов
+ 4
this code works, the problem is you include 1000. it says below 1000 so max is 999.
+ 3
I think your code could be a lot shorter if you only want to calculate result.
0
thank you. my bad :v