Card

A standard playing card.

There are 52 cards in a standard playing card deck.

There are 4 suits:

suits
['♣️', '♦️', '❤️', '♠️']

And there are 14 ranks:

ranks
[None, 'A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']

Note that the first rank is None so that numeric ranks correspond to their indices. For example:

ranks[5]
'5'

source

Card

 Card (suit=0, rank=1)

A standard playing card.

Create a card by passing in numbers representing its suit and rank:

card = Card(suit=2, rank=12)
card
Q❤️
assert repr(Card()) == "A♣️"

You can compare two cards using Python’s built-in operators:

assert Card(suit=0, rank=2) < Card(suit=0, rank=10)
assert Card(suit=0, rank=2) < Card(suit=1, rank=2)
assert Card(suit=1, rank=2) > Card(suit=0, rank=2)
assert Card(suit=0, rank=2) == Card(suit=0, rank=2)