list = [1, 2, 3, 4, 5, 6, 7, 8, 9]list_2 = []
for i in range(len(list)):
if list[i] % 2 == 0:
list_2.append(list[i])
print(list_2)
# [2, 4, 6, 8]
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
list_2 = []
for i in range(len(list)):
if list[i] % 2 == 0:
list_2.append(list[i])
print(list_2)
# [2, 4, 6, 8]