Custom Search

Saturday, April 16, 2011

python iterate over the whole list in 2 increments

The step argument in slice operators

a = [1,2,3,4,5]
>>> a[::2]
[1,3,5]

No comments:

Post a Comment