cards

A minimal example of nbdev based on Allen Downey’s Think Python 2nd Ed

Install

pip install cards

How to use

from cards.deck import Deck

Create a Deck of standard playing cards:

deck = Deck()
deck
A♣️ 2♣️ 3♣️ 4♣️ 5♣️ 6♣️ 7♣️ 8♣️ 9♣️ 10♣️ J♣️ Q♣️ K♣️ A♦️ 2♦️ 3♦️ 4♦️ 5♦️ 6♦️ 7♦️ 8♦️ 9♦️ 10♦️ J♦️ Q♦️ K♦️ A❤️ 2❤️ 3❤️ 4❤️ 5❤️ 6❤️ 7❤️ 8❤️ 9❤️ 10❤️ J❤️ Q❤️ K❤️ A♠️ 2♠️ 3♠️ 4♠️ 5♠️ 6♠️ 7♠️ 8♠️ 9♠️ 10♠️ J♠️ Q♠️ K♠️

Decks work like ordinary Python lists. Draw a Card from the deck with deck.pop:

card = deck.pop()
card
K♠️