Deck or 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:

deck = Deck()
c = Card(2,3)
deck.remove_card(c)

assert c 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.

c2 = Card(2,10)
assert c2 in deck.cards