card

A simple API for creating and using playing cards
suits
['♣️', '♦️', '♥️', '♠️']

for example the suit ar index 0:

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

for exampel the rank at index 1 (note no rank at index 1 so that 2 - 10 match)

ranks[1]
'A'

source

Card

 Card (suit:int, rank:int)

A playing card

Type Details
suit int An index into suits
rank int an index into ranks
c = Card(suit=1, rank=3)
c
3♦️

Comparison opperators

equality, less than, and greater than should work on rank and suit indicies

test_eq(Card(suit=1, rank=3), Card(suit=1, rank=3))
test_ne(Card(suit=1, rank=12), Card(suit=3, rank=12))
test_ne(Card(suit=1, rank=3), Card(suit=3, rank=3))

assert Card(suit=1, rank=3) < Card(suit=2, rank=3)

assert Card(suit=3, rank=3) > Card(suit=2, rank=3)
assert not Card(suit=1, rank=3) > Card(suit=2, rank=3)