How to create linked list automatically
Dave Hansen
iddw at hotmail.com
Mon Dec 19 16:13:17 EST 2005
More information about the Python-list mailing list
Mon Dec 19 16:13:17 EST 2005
- Previous message (by thread): How to create linked list automatically
- Next message (by thread): How to create linked list automatically
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, 19 Dec 2005 20:51:39 +0000 in comp.lang.python, Simon Brunning <simon at brunningonline.net> wrote: >I haven't the time (or inclination) to sort out all your problems >here, but one thing jumps out at me: > >On 12/19/05, Shahriar Shamil Uulu <shamilsons at yahoo.com> wrote: >> class Node: >> def __init__(self,name=None,next=None): >> self.name=name >> self.next=next >> >> def __str__(self): >> return str(self.name) > >Your Node classes str() prints the instances self.name attribute, >which is set by an optional named argument on the initialiser... > >> w=[] >> for i in range(10): >> node=Node(i) > >... but you aren't providing this argument when you build your Node objects... Actually, he is. Look closer. As /F pointed out, his problem is in the linking. By making a small modification to his code, I was able to get it to print 1 2 3 4 5 6 7 8 9 None As (I assume) was expected. I'd post the code, but the margin is too small to contain it... Besides, I'd like the OP to figure it out himself. Regards, -=Dave -- Change is inevitable, progress is not.
- Previous message (by thread): How to create linked list automatically
- Next message (by thread): How to create linked list automatically
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list