How to create linked list automatically

Fredrik Lundh fredrik at
Mon Dec 19 21:30:35 CET 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]

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?)


More information about the Python-list mailing list