[Tutor] Iterate by twos
W W
srilyk at gmail.com
Sun Nov 2 20:53:40 CET 2008
is there a better/more pythonic way to do something like this?
spam = ['c','c','v','c','v']
for x in xrange(0,5,2):
print spam[x], spam[x+1]
There are other things I'll be doing with the values, but I want to get them
in chunks of two. (I realize that this code will throw errors, it's just a
hasty example of what I need)
Thanks,
Wayne
--
To be considered stupid and to be told so is more painful than being called
gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness,
every vice, has found its defenders, its rhetoric, its ennoblement and
exaltation, but stupidity hasn't. - Primo Levi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20081102/dc67d41e/attachment.htm>
More information about the Tutor
mailing list