Nested Loops all
<p>I am using python. The assignment is simple, I understand the concept, I have zero knowledge of computer programming, so be gentle and please try to explain everything in much detail as if I know nothing, I am trying my best to learn. This is to show that with all combinations ijk, ikj, jik, jki, kij, and kji return the same result. The next step is to do the same thing with 4000. (try to figure how to put 4000 in matrix, shoot myself.) 
I know there are things like numpy but I have no idea how to use that, but I was going to try and start with the basics, straight from windows terminal. I would like to thank you for your time and help here guys! thanks!!!enter code here</p>

<pre><code>enter code here

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



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



    result = [[0,0],
             [0,0]]
     empty = [[0,0],
             [0,0]]

        for i in range(len(X)):
             for j in range(len(Y[0])):
                  for k in range(len(Y)):
                        result[i][j] += X[i][k] * Y[k][j]
for r in result:
    print r
    result = empty
    del r[:]


print""

for i in range(len(X)):
    for k in range(len(Y)):
        for j in range(len(Y[0])):
            result[i][j] += X[i][k] * Y[k][j]

for r in result:
    print r
    del r[:]


print""

for i in range(len(X)):
    for k in range(len(Y)):
        for j in range(len(Y[0])):
           result[i][j] += X[i][k] * Y[k][j]

for r in result:
    print r
    result = empty
    del r[:]
    del range[:]

print""

for j in range(len(Y[0])):    
    for i in range(len(X)):
        for k in range(len(Y)):
            result[i][j] += X[i][k] * Y[k][j]

for r in result:
    print r
    result = empty
    del r[:]

for j in range(len(Y[0])):
    for k in range(len(Y)):
        for i in range(len(X)):
            result[i][j] += X[i][k] * Y[k][j]

for r in result:
    print r
    result = empty
    del r[:]

for k in range(len(Y)):
    for i in range(len(X)):
        for j in range(len(Y[0])):
            result[i][j] += X[i][k] * Y[k][j]

 for r in result:
    print r
    result = empty
    del r[:]

for k in range(len(Y)):
    for j in range(len(Y[0])):
        for i in range(len(X)):
            result[i][j] += X[i][k] * Y[k][j]

for r in result:
    print r
    result = empty
    del r[:]
</code></pre>

<p>The problem, is the index, when running the code for the 3rd set, there is a  problem with the index, I can't figure that out.</p>

<pre><code>          result[i][j] += X[i][k] * Y[k][j]
        IndexError: list index out of range
</code></pre>

<p>I printed <code>i</code>, <code>j</code>, <code>k</code> and <code>result[i][j]</code>, <code>X[i][k]</code>, <code>Y[k][j]</code> in 3rd set and found:</p>

<p>You forgot <code>result = empty</code></p>

<p>But there is another problem:  <code>result = empty</code> doesn't duplicate list but assigns the same list to two variables. So when you delete <code>r[:]</code> the you delete <code>result</code> and <code>empty</code> and get empty list <code>[]</code> and doesn't exist even <code>result[0][0]</code>.</p>

<p>You need <code>result = empty[:]</code> to duplicate <code>empty</code> and assign to <code>result</code>. </p>

<pre><code>X = [[1,2,3,4,5],
    [6,7,8,9,10]]

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

result = [[0,0],
         [0,0]]

empty = [[0,0],
         [0,0]]


for i in range(len(X)):
     for j in range(len(Y[0])):
          for k in range(len(Y)):
                result[i][j] += X[i][k] * Y[k][j]

for r in result:
    print r
print

result = empty[:]

for i in range(len(X)):
    for k in range(len(Y)):
        for j in range(len(Y[0])):
            result[i][j] += X[i][k] * Y[k][j]

for r in result:
    print r
print

result = empty[:]

for i in range(len(X)):
    for k in range(len(Y)):
        for j in range(len(Y[0])):
           result[i][j] += X[i][k] * Y[k][j]

for r in result:
    print r
print

result = empty[:]

for j in range(len(Y[0])):    
    for i in range(len(X)):
        for k in range(len(Y)):
            result[i][j] += X[i][k] * Y[k][j]

for r in result:
    print r
print

result = empty[:]

for j in range(len(Y[0])):
    for k in range(len(Y)):
        for i in range(len(X)):
            result[i][j] += X[i][k] * Y[k][j]

for r in result:
    print r
print

result = empty[:]

for k in range(len(Y)):
    for i in range(len(X)):
        for j in range(len(Y[0])):
            result[i][j] += X[i][k] * Y[k][j]

for r in result:
    print r
print

result = empty[:]

for k in range(len(Y)):
    for j in range(len(Y[0])):
        for i in range(len(X)):
            result[i][j] += X[i][k] * Y[k][j]

for r in result:
    print r
print

result = empty[:]   
</code></pre>

python loops matrix indexing nested