I am using Python 2.5, I want an enumeration like so (starting at 1 instead of 0):
[(1, 2000), (2, 2001), (3, 2002), (4, 2003), (5, 2004)]
Simplest way to do in Python 2.5 exactly what you ask about:
import itertools as it
... it.izip(it.count(1), xrange(2000, 2005)) ...
If you want a list, as you appear to, use zip
in lieu of it.izip
.
(BTW, as a general rule, the best way to make a list out of a generator or any other iterable X is not [x for x in X]
, but rather list(X)
).