I need to check if the number the user is inserting is in colum, row or "block" (still working on the last part). for some reason, these checks do not work, and I do not understand why?
I wrote the same code in the shell and it worked fine.
my code is:
def is_valid_move(board,row, column, digit): if digit in board[row]: print "Row already contains", digit return (False) else: return (True) for i in range(9): if digit in board[i][row]: print "Colum already contains", digit return (False) break else: return (True) board = [[3,7,0,0,5,0,0,0,0], [0,6,0,0,3,0,2,0,0], [0,2,9,4,0,0,0,7,8], [0,0,4,1,7,0,0,8,0], [0,0,6,3,0,5,9,0,0], [0,5,0,0,8,4,1,0,0], [7,1,0,0,0,8,5,6,0], [0,0,5,0,1,0,0,2,0], [0,0,0,0,9,0,0,1,3]] a=is_valid_move(board,1, 2, 9) print a
output:
True
any idea how to check if the number is in the box?
Thanks!