[Tutor] List problem
Andre Engels
andreengels at gmail.com
Mon Jul 25 07:57:19 CEST 2011
On Mon, Jul 25, 2011 at 4:19 AM, David Merrick <merrickdav at gmail.com> wrote:
> def append(self,item):
> '''Adds an item to the end of the List'''
>
> current = self.head
> previous = None
> while current.getNext() != None:
> previous = current
> current = current.getNext()
> if current.getNext() == None:
> previous = previous.setNext(current)
> current = current.setNext(item)
>
current is here the first element of your list. This element does not have a
getNext() method. Instead, if you want to use this system, you'll have to
use a (probably re-defined) getNext() method of your list class itself.
--
André Engels, andreengels at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110725/51123049/attachment.html>
More information about the Tutor
mailing list