In [1]:
total = 0
for i in range(1000):
    if i % 3 == 0 or i % 5 == 0:
        total += i
print total


233168

In [2]:
total = 0
for i in range(1000):
    if i % 3 == 0:
        total += i
    if i % 5 == 0:
        total += i
print total


266333

In [3]:
sum(filter((lambda x: x % 3 == 0 or x % 5 == 0), range(1000)))


Out[3]:
233168