[Tutor] strange listed nest behaviour

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Jun 30 19:21:58 EDT 2004



On Wed, 30 Jun 2004, Dave S wrote:

> I have a problem with lists,
>
> As an example the following makes sense to me and works as I would
> expect ...
>
>  >>> b=[[0,0,0,0],[0,0,0,0]]
>  >>> b
> [[0, 0, 0, 0], [0, 0, 0, 0]]
>  >>> b[1][1]=5
>  >>> b
> [[0, 0, 0, 0], [0, 5, 0, 0]]
>  >>>
>
> However I have to set up a large data list, so I have used
> "self.startslot=[[float(0)]*110]*36" inside a class.

Hi Dave,

Today seems like a FAQ-referral day for me.  *grin*


Here you go:

http://www.python.org/doc/faq/programming.html#how-do-i-create-a-multidimensional-list


Hope this helps!




More information about the Tutor mailing list