[Tutor] strange listed nest behaviour (original) (raw)

Dave S pythontut at pusspaws.net
Thu Jul 1 03:04:30 EDT 2004


Danny Yoo wrote:

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! Its perfect :-) ... I will read the FAQ. I have been learning my Python from o'reilly and did not realise there was a FAQ on line - thats great cheers

Dave

PS thanks for your patience with us newbes !



More information about the Tutor mailing list