class Stock:
    def __init__(self, symbol):
        self.symbol = symbol
        self.price = None

    def update(self, timestamp, price):
        if price < 0:
            raise ValueError("price should not be negative")
        self.price = price

class Stock:
    def __init__(self, symbol):
        self.symbol = symbol
        self.price_history = []

    @property
    def price(self):
        if self.price_history:
            return self.price_history[-1]
        else:
            return None

    def update(self, timestamp, price):
        if price < 0:
            raise ValueError("price should not be negative")
        self.price_history.append(price)

Update price attribute to price_history list as well as update function accordingly.
Update price attribute to price_history list as well as update function accordingly.

  class Stock:
      def __init__(self, symbol):
          self.symbol = symbol
-         self.price = None
+         self.price_history = []
+ 
+     @property
+     def price(self):
+         if self.price_history:
+             return self.price_history[-1]
+         else:
+             return None
  
      def update(self, timestamp, price):
          if price < 0:
              raise ValueError("price should not be negative")
-         self.price = price
+         self.price_history.append(price)
  
Update price attribute to price_history list as well as update function accordingly.
## Code Before:
class Stock:
    def __init__(self, symbol):
        self.symbol = symbol
        self.price = None

    def update(self, timestamp, price):
        if price < 0:
            raise ValueError("price should not be negative")
        self.price = price

## Instruction:
Update price attribute to price_history list as well as update function accordingly.
## Code After:
class Stock:
    def __init__(self, symbol):
        self.symbol = symbol
        self.price_history = []

    @property
    def price(self):
        if self.price_history:
            return self.price_history[-1]
        else:
            return None

    def update(self, timestamp, price):
        if price < 0:
            raise ValueError("price should not be negative")
        self.price_history.append(price)
