+ 3

In one-dimensional list a=[a1, a2, ..., an] all positive elements that have an even sequence number, rewrite the beginning....

In one-dimensional list a=[a1, a2, ..., an] all positive elements that have an even sequence number, rewrite the beginning of the list. in Python

4th Apr 2018, 6:34 PM
Пиров Мустафо
Пиров Мустафо - avatar
1 Resposta
+ 3
a = [a[i] for i in range(0, len(a)) if i % 2 == 0]
4th Apr 2018, 7:04 PM
Bartosz Pieszko
Bartosz Pieszko - avatar