Note this:
>>> matrix = [[0] * 3] * 3
>>> [x for x in matrix]
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
>>> [id(x) for x in matrix]
[32484168, 32484168, 32484168]
>>>
Three rows but only one object.
See the docs especially Note 2 about the s * n operation.
Fix:
>>> m2= [[0] * 3 for i in xrange(5)]
>>> [id(x) for x in m2]
[32498152, 32484808, 32498192, 32499952, 32499872]
>>>
Update: Here are some samples of code that gets an answer simply (i.e. without iter()):
>>> nrows = 2; ncols = 4
>>> zeroes = [[0 for j in xrange(ncols)] for i in xrange(nrows)]
>>> zeroes
[[0, 0, 0, 0], [0, 0, 0, 0]]
>>> ap = [[ncols * i + j for j in xrange(ncols)] for i in xrange(nrows)]
>>> ap
[[0, 1, 2, 3], [4, 5, 6, 7]]
>>>