2D lists

Carl Banks imbosol at vt.edu
Mon Jan 20 23:42:09 CET 2003


Marcin Matuszkiewicz wrote:
> What is a most efficient way to create an intialized 2D list?

If each item is initialized separately, then:

a = [ [1,2,3], [4,5,6], [7,8,9] ]


If each item is initialized to a single value, then probably (I recall
a discussion about it):

a = map(list,([0]*3)*4)


-- 
CARL BANKS




More information about the Python-list mailing list