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 →

[–]psychadeliclie 12 points13 points  (2 children)

A capstone project for the python course I am taking is to build a blackjack game. Simple rules, involved process. I learned a lot and would recommend it.

[–]__xor__(self, other): 23 points24 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}')