Wednesday, April 29, 2009

Use append to construct 2-dimension array

How to use array.append to construct or build 2-dimension array?

Here we go! Do it lie following step!
===============================
#create two-dimensional array
arr = []
for line in startfile.readlines():
    littlearr = []
    for letter in line.strip():
        littlearr.append(letter)
    arr.append(littlearr)
===============================

No comments:

Clicky

Clicky Web Analytics