classStockSpanner:def__init__(self): self.stack = [] # This stack will keep track of stock prices and their spansdefnext(self,price:int) ->int: span_count =1while self.stack and self.stack[-1][0] <= price: span_count += self.stack.pop()[1] self.stack.append((price, span_count))return span_count