Ben Finney wrote:
[snip]
>
> Please don't write C in Python. The 'for' statement allows iteration
> directly over a sequence, no need to maintain an index. Also, the
> modulus operator is called for with your cycling of the pile index.
>
>         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)


Gerard

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to