In [1]:
total = 0
for i in range(1000):
if i % 3 == 0 or i % 5 == 0:
total += i
print total
In [2]:
total = 0
for i in range(1000):
if i % 3 == 0:
total += i
if i % 5 == 0:
total += i
print total
In [3]:
sum(filter((lambda x: x % 3 == 0 or x % 5 == 0), range(1000)))
Out[3]: