from itertools import product
groups = {i: [] for i in range(1,28)}
for i in range (100, 1000):
groups[i // 100 + i // 10 % 10 + i % 10].append[i]
results = []
for i in groups:
results += [x*1000+y for x,y in product(groups[i], repeat=2)]
print(results)