for parts builds a small deck of card objects.
class Card:
def __init__(self, rank, suit):
self.rank = rank
self.suit = suit
def __str__(self):
return self.rank + self.suit
deck = [Card(r, s) for s in "HS" for r in "AK"]
print([str(c) for c in deck], len([c for c in deck if c.suit == "S"]))
What does the program print?Log in to join the discussion.
Loading…