WORKING WITH MATRICES
A two-dimensional matrix is a two-dimensional array of values. The following code block illustrates how to access different elements in a 2D matrix:
mm = [["a","b","c"],["d","e","f"],["g","h","i"]];
print 'mm: ',mm
print 'mm[0]: ',mm[0]
print 'mm[0][1]:',mm[0][1]
The output from the preceding code block is as follows:
mm: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']]
mm[0]: ['a', 'b', 'c']
mm[0][1]: b
Listing 3.9 shows the content of My2DMatrix.py that illustrates how to create and populate 2 two-dimensional matrices.
Listing 3.9: My2DMatrix.py
rows = 3
cols = 3
my2DMatrix = [[0...