I'm trying to set this in Python. I think that I am close but not quite sure where to go with it. I want each section of list to fill in each row of Sudoku layout, but I can only get it to fill in the whole list in each section. Could I get some advice on a direction to take?
list = [[5,0,0,0,0,0,0,0,0],[0,9,0,7,0,0,8,0,0],[0,0,0,0,3,0,0,7,0],[6,0,1,0,0,0,9,8,0],[0,0,0,6,0,0,0,0,0],[0,0,9,0,0,0,7,0,1],[0,0,0,0,0,8,1,9,0],[0,4,0,5,0,1,0,0,8],[0,7,0,3,0,6,0,4,0]]
for c in range(3):
if c == 0 or 2 or 8:
print('+-------+-------+-------+')
for x in list:
row = '| '
for y in range(0,9):
if x[y] == 0:
x[y] = '.'
row += x[y] + ' '
else:
row += str(x[y]) + ' '
if y == 2:
row += '| '
if y == 5:
row += '| '
if y == 8:
row += '| '
# if y == 3 or 7 or 8:
# row += '| '
print(row)
row = '\n'
print('+-------+-------+-------+')
I haven't tried too much as most of what I do messes up the layout of the grid, but I have tried moving the start and end point of the for loops and moving it to where the print(row) sits but I end up with really off-the-wall results; i.e., I get nothing or the bar that is supposed to concatenate in prints every other line.