Playing Cards

class Deck[source]

Deck()

Represents a deck of cards. Attributes: cards: list of Card objects.

A Deck of cards is a collection of Card objects:

deck = Deck()
assert isinstance(deck.pop_card(), Card)

Deck.remove_card[source]

Deck.remove_card(card)

Removes a card from the deck or raises exception if it is not there.

card: Card

If we remove a card from the Deck we can verify that it no longer exists:

card23 = Card(2, 3)
deck.remove_card(card23)

assert card23 not in deck.cards

However, another card that we haven't removed, such as the 10 of hearts will still be in the Deck of cards because we haven't removed it:

c = Card(2,10)
assert c in deck.cards
c
10 of Hearts