I'm trying to understand some of Python's built in heap functionality. It seems to not like things when I pass in a list of tuples (or more likely, I'm not passing the list in correctly). Here is what I have:
myList = ( ('a', 1), ('b', 2) )
heapify(myList)
The error that I get is
TypeError: heap argument must be a list
Am I doing something wrong? Is there another way to pass in a list of tuples?
Thanks!
The problem is that myList
is a tuple. Try this:
myList = [('a', 1), ('b', 2)]
heapify(myList)