[Tutor] for: how to skip items
Andreas Perstinger
andipersti at gmail.com
Mon Feb 17 17:35:37 CET 2014
Gabriele Brambilla <gb.gabrielebrambilla at gmail.com> wrote:
>it's because my problem is not so simple:
>imagine that in a100 contains not integer sorted in a good way but a
>random float numbers.
>How could I display only one item every 10?
You can provide a step size if you slice a list:
>>> l = list(range(10))
>>> l[0:10:2]
[0, 2, 4, 6, 8]
>>> l[0:10:5]
[0, 5]
Is that what you want?
Bye, Andreas
More information about the Tutor
mailing list