x = int(input("x = "))
i = 0
ch = []
n_ch = []
s = 0
while i:
----i += 1
----print(i,end=" ")
----if i % 2==0:
--------ch.append(i)
----else:
--------n_ch.append(i)
----s += i
print('\nЧетние числа ',ch)
print('Не четние числа ',n_ch)
print("Сума =",s)
Пример:
x = 501 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
Четние числа [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]
Не четние числа [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]
Сума = 1275