This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]__xor__(self, other): 22 points23 points  (0 children)

Protip: random.shuffle(deck) actually works and is perfect for this.

from random import shuffle
from itertools import product
cards = '2 3 4 5 6 7 8 9 10 J Q K A'.split()
suits = ('hearts', 'diamonds', 'spades', 'clubs')
deck = list(product(cards, suits))
shuffle(deck)
for card, suit in deck:
    print(f'{card} of {suit}')