On Fri, Aug 28, 2009 at 10:49 AM, kevin parks <k...@me.com> wrote: > > Thanks for the replies. Though the list comprehension does not work: > > TypeError: enumerate() takes exactly 1 argument (2 given) > > > On Aug 29, 2009, at 12:20 AM, vince spicer wrote: > > >> >> #print foohough I didn't test your code, I think what you are trying >> to accomplish can be done using enumerate cleaner >> >> >> def pack(foo): >> out = [] >> for x,y in enumerate(foo, 1): >> out.append((x,y)) >> return out >> >> >> >> >> Or even cleaner with list comprehension >> >> def pack(foo): >> return [x for x in enumerate(foo, 1)] >> >> >> > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor >
What version of python are using, python 2.6+ have a "start" parameter http://docs.python.org/library/functions.html#enumerate
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor