Lists and Indices
Mark McEahern
marklists at mceahern.com
Thu Aug 8 13:45:39 EDT 2002
> I currently use
>
> index=1
> for color in colors:
> print '%d. %s' % (index, color)
> index += 1
>
> but that does not seem pretty to me;
You could wait for 2.3's enumerate(), otherwise, I'd spell this essentially
the way you said was unreadable:
for i in range(len(colors)):
item = colors[i]
print "%d. %s" % (i, item)
what's so unreadable about it, I wonder?
// m
-
More information about the Python-list
mailing list