'''
https://snakify.org/lessons/two_dimensional_lists_arrays/

Suppose that two numbers are given: the number of rows of n and the number of columns m.
You must create a list of size n * m, filled with, say, zeros

n = 3
m = 4
a = [[0] * m] * n
print a
[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]


'''


'''
https://www.programiz.com/python-programming/examples/multiply-matrix
'''


# Program to multiply two matrices using nested loops

# 3x3 matrix
X = [[12,7,3],
     [4 ,5,6],
     [7 ,8,9]]
# 3x4 matrix
Y = [[5,8,1,2],
     [6,7,3,0],
     [4,5,9,1]]
# result is 3x4
result = [[0,0,0,0],
          [0,0,0,0],
          [0,0,0,0]]


# result = [[0] * 4] * 3




# iterate through rows of X
for i in range(len(X)):
    # iterate through columns of Y
    for j in range(len(Y[0])):
        # iterate through rows of Y
        for k in range(len(Y)):
            result[i][j] += X[i][k] * Y[k][j]

for r in result:
    print(r)

'''
O/P :
[114, 160, 60, 27]
[74, 97, 73, 14]
[119, 157, 112, 23]
'''

'''
Source Code: Matrix Multiplication Using Nested List Comprenhension
https://www.programiz.com/python-programming/examples/multiply-matrix
'''
