array = [1,2,3,4,5,6,7,8,9]
newarray = [array[i] for i in range(0, len(array), 2)]
print(newarray)
The result is [1, 3, 5, 7, 9]
.
solved how do i write a list comprehension?
array = [1,2,3,4,5,6,7,8,9]
newarray = [array[i] for i in range(0, len(array), 2)]
print(newarray)
The result is [1, 3, 5, 7, 9]
.
solved how do i write a list comprehension?