total = [] for num in range(0,1001): if (num % 3 == 0) or (num % 5 == 0): total.append(num) print(sum(total))