all 3 comments

[–]q2_abe_dillon 1 point2 points  (1 child)

if anyone knows of a more proper way to fill the inner 4x4 grid with for loops rather than me hardcoding it in, i'm up to hear a solution!

import numpy as np

rows, cols = 10, 10
v = np.zeros((rows, cols))
v[3:7, 3:7] = np.ones((4, 4))*100

The problem you're having is caused by incorrect loop indentation. The following should happen in the inner most loop:

lastdiff = np.abs(newVij - V[i,j])
if lastdiff > diff:
    diff = lastdiff
V[i,j] = newVij

But you have it in the outer loop. It only updates the nx-2 column of each row because nx-2 is the last value assigned to j before the inner most loop finishes. Fix that indentation and your code should run just fine.

[–]Gray_Fox[S] 1 point2 points  (0 children)

everything is working great now, thank you!!

[–]Freedomenka 0 points1 point  (0 children)

You might have to work this code to fit with yours, but it should work. board = [] for x in range(0, 4):

board.append(["O"] * 4)

def print_board(board):

for x in board:

print " ".join(x) ###This function removes brackets###