"Gerard Flanagan" <[EMAIL PROTECTED]> writes: > Ben Finney wrote: > > pile_index = 0 > > for card in deck: > > piles[pile_index].append(card) > > pile_index = (pile_index + 1) % numpiles > > > > no need to maintain an index ;-) > > piles = [ list() for _ in range(n) ] > for i, card in enumerate(deck): > piles[i % numpiles].append(card)
That's a matter of style. I prefer what I wrote, since I've given an explicit name to the calculation you're doing inside the [] operator; that way, anyone reading the code knows *why* the calculation is done in this particular case. If, of course, the index was a simple increment-by-one each time, your 'enumerate' usage would be clearer. -- \ "We spend the first twelve months of our children's lives | `\ teaching them to walk and talk and the next twelve years | _o__) telling them to sit down and shut up." -- Phyllis Diller | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list