Skip to content
Code ReadingPop the Smallest
Predict the Output

Pop the Smallest

heapq always hands out the smallest first. What is printed?
1import heapq
2
3h = [5, 1, 8, 3]
4heapq.heapify(h)
5heapq.heappush(h, 2)
6print(heapq.heappop(h), heapq.heappop(h), len(h))