For Counter Variable

Prasad, Ramit ramit.prasad at jpmorgan.com
Thu Sep 27 13:34:45 EDT 2012


Tim Chase wrote:
> [snip] though I'm minorly miffed that
> enumerate()'s starting-offset wasn't back-ported into earlier 2.x
> versions and have had to code around it for 1-based indexing; either
> extra "+1"s or whip up my own simple enumerate() generator).


Starting offset is in Python 2.6, unless you meant
earlier than 2.6.

>>> for idx, x in enumerate( xrange(5), 10 ):
...     print idx, x
...     
10 0
11 1
12 2
13 3
14 4

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  


More information about the Python-list mailing list