Lists Of Class Objects

A class may have a property that is list and contains class instances.




  • At line 12 an empty list is created.
  • At lines 32 - 34 elements are added to the list.
  • At line 16 the list is sorted ascending by price. If we replace line 16 with x: x.price, reverse=True), then the sorting would be descending.