class ShoppingCart:
def __init__(self):
self.cart = []
def add_item(self, item):
""" (ShoppingCart, Item) -> NoneType
Adds an item to the cart.
"""
self.cart.append(item)
def show_cheapest_item(self):
""" (ShoppingCart) -> int
Return the cheapest item in the cart, or -1 if no items are in the cart
"""
# my point of confusion
class Item:
""" An instance of an item """
def __init__(self, price):
""" (Item, float)
Initialize an Item
"""
self.price = price
Я пытаюсь вернуть дешевый товар в корзину, однако, я не могу получить доступ к прайс-лист в любом случае.найти наименьшее значение внутри экземпляра переменной
Пожалуйста, пост полный код обоих классов – alfasin