[Tutor] remove function

Christopher Spears cspears2002 at yahoo.com
Thu Jul 27 04:59:46 CEST 2006

Here is a class called PriorityQueue:

class PriorityQueue:
	def __init__(self):
		self.items = []
	def isEmpty(self):
		return self.items == []
	def insert(self, item):
	def remove(self):
		maxi = 0
		for i in range(1, len(self.items)):
			if self.items[i] > self.items[maxi]:
				maxi = i
		item = self.items[maxi]
		return item
My question concerns the remove function.  The
function returns the maximum value.  However, I'm
curious about
self.items[maxi:maxi+1] = [].  I understand that the
programmer wants to remove self.items[maxi].  Why
would he or she want to remove that value and the one
next to it (maxi+1)?  Or am I misunderstanding 	
self.items[maxi:maxi+1] = [] ?

As an aside, I can't figure out how to respond to
topics on this list.

More information about the Tutor mailing list