[Tutor] remove function

Alan Gauld alan.gauld at freenet.co.uk
Thu Jul 27 09:37:00 CEST 2006


> 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] = [].  

Me too. Where did you find that line?

> 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] = [] ?

Slicing does not include the top number, it works 
like range() Thus a slice [3:4] only includes [3]

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

Use Reply-All... or if you don;t have that simply add 
the tutor address to the cc list.

Alan G.



More information about the Tutor mailing list