Create a class named with ‘Card’, which has two attributes, ‘rank’ and ‘suit’, when you call this class and transfer the atrributes, the order of the atrribute should be the same with defined atrribute.
Which is used to build classes of objects that are just the bundles of attributes with no custom methods, like a database record.
>>> for card insorted(deck, key=spades_high): print(card) ...
Summary
By implementing the special methods __len__ and __getitem__, our FrenchDeck behaves like a standard Python sequence, allowing it to benefit from core language features (e.g., iteration and slicing) and from the standard library, as shown by the examples using random.choice, reversed and sorted. Thanks to composition, the __len__ and __getitem__ implementations can hand off all the work to a list object, self._cards.