fork download
  1. import heapq
  2. q = []
  3. heapq.heappush(q, 3)
  4. heapq.heappush(q, 1)
  5. heapq.heappush(q, 4)
  6. top = q[0]
  7. print('top = {}'.format(top))
  8. has_element = q == []
  9. print('is_empty = {}'.format(has_element))
  10. popped = heapq.heappop(q)
  11. print('popped = {}'.format(popped))
  12. print('q[0] = {}'.format(q[0]))
  13.  
Success #stdin #stdout 0.02s 9132KB
stdin
Standard input is empty
stdout
top = 1
is_empty = False
popped = 1
q[0] = 3