l = []; index = 0; for item in range(1, 1000): if item % 6 == 0 and item % 8 == 0: if index == 3: break; else: index += 1; l.append(item) print(l)