diff --git a/MaxHeap.py b/MaxHeap.py index 0168aae5..6da6d305 100644 --- a/MaxHeap.py +++ b/MaxHeap.py @@ -15,8 +15,9 @@ def push(self, data): self.__floatUp(len(self.heap) - 1) def peek(self): - if self.heap[1]: - return self.heap[1] + if len(self.heap)>=2: + if self.heap[1]: + return self.heap[1] else: return False