[Tutor] packing a list of lists
kevin parks
kp8 at me.com
Fri Aug 28 18:49:40 CEST 2009
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)]
>
>
More information about the Tutor
mailing list