0

Example:

class Card:
    def __init__(self,suit,rank):
        self.suit=suit
        self.rank=rank

class Deck:
        def __init__(self):
            self.all_cards = []
            for suit in suits:
                for rank in ranks:
                    self.all_cards.append(Card(suit,rank))

Can someone please explain how the class attributes for Card stored as? When I access the card class in Deck are the attributes retrieved as a tuple?

Junaid
  • 159
  • 1
  • 15
ratsi
  • 1
  • 1
  • 2
  • 1
    See https://stackoverflow.com/questions/48029249/python-dict or https://stackoverflow.com/questions/19907442/explain-dict-attribute – Thierry Lathuille Apr 16 '21 at 17:05
  • The `Card` objects are stored in a **list** of `d.all_cards` where `d` is an instance of `Deck`. Each card object's attributes are stored in the instance dictionary (`c.__dict__` where `c` is an instance of `Card`). – aneroid Apr 16 '21 at 17:19

0 Answers0