Cutting a deck of cards
Ian Kelly
ian.g.kelly at gmail.com
Sun May 26 14:28:59 EDT 2013
On Sun, May 26, 2013 at 12:17 PM, RVic <rvince99 at gmail.com> wrote:
> Ah, brilliant -- yes, this is so much more elegant in Python:
>
> #now cut the cards
> x = random.randrange(2,range(13 * 4 * decks))
> cards = cards[x:]+cards[:x]
Or if for some reason you want to do it in place:
cards[x:], cards[:x] = cards[:x], cards[x:]
But note that the order of assignments is subtly important there, so
unless you have a good reason for doing that, it's probably better
just to create a new list for clarity.
More information about the Python-list
mailing list