threes = [] fives = [] for i in range(1000): if i % 3 == 0: threes.append(i) elif i % 5 == 0: fives.append(i) print(sum(threes) + sum(fives))