[Tutor] Fwd: for: how to skip items
ugajin at talktalk.net
ugajin at talktalk.net
Mon Feb 17 18:01:17 CET 2014
0, 9, 19, 29, 39, is not every 10th index
If you want to output every 10th. index try:
a100 = list(range(0,100,10))
for a in a100:
print(a)
-----Original Message-----
From: Gabriele Brambilla <gb.gabrielebrambilla at gmail.com>
To: python tutor <tutor at python.org>
Sent: Mon, 17 Feb 2014 16:06
Subject: [Tutor] for: how to skip items
Hi,
I'm wondering how I can (if I can) make a for loop in which I don't use all the elements.
for example
a100 = list(range(100))
for a in a100:
print(a)
it print out to me all the numbers from 0 to 99
But if I want to display only the numbers 0, 9, 19, 29, 39, ...(one every 10 elements) how can I do it WITHOUT defining a new list (my real case is not so simple) and WITHOUT building a list of indexes?
thank you
Gabriele
_______________________________________________
Tutor maillist - Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140217/6a738434/attachment.html>
More information about the Tutor
mailing list