How to create linked list automatically

Fredrik Lundh fredrik at pythonware.com
Mon Dec 19 15:30:35 EST 2005


"Shahriar Shamil Uulu" wrote:

> w=[]
> for i in range(10):
>     node=Node(i)
>     w.append(node)
>
> for i in range(10):
>     a=w[i]
>     if i+1>9:
>         b=w[9]
>         a.next=b

I'm not sure what you're trying to do here, but I'm quite sure that this
code doesn't do what you think it does.

(hint: i will range from 0 to 9.  what happens when i=0?  what happens
when i=9?)

</F>






More information about the Python-list mailing list