please help shrink this each_with_index() implementation
Carsten Haese
carsten.haese at gmail.com
Tue Jan 5 15:22:51 EST 2010
Phlip wrote:
> Hypo Nt:
>
> def each_with_index(seq):
> index = 0
> result = []
>
> for item in seq:
> result.append([item, index])
> index += 1
>
> return result
>
> My Pythonic sequencing skills are obviously feeble. Can anything think
> of a way to write that in fewer lines?
Couldn't you just use the built-in enumerate() to replace the whole thing?
--
Carsten Haese
http://informixdb.sourceforge.net
More information about the Python-list
mailing list