def diag_bl_tr_checker(row, column, board): if row == column: if board[0][0] == board[1][1] == board[2][2]: return 1 else: return 0
The problem with the code is the first if statement, which checks if the row is equal to the column, and this was also a problem with the other function, which checked if the row added to the column equaled 2. If the first if statement evaluated to false, the code wouldn't return anything, and its addition into the
flag_number
variable wouldn't work because it was not a number, so it gave an error.
flag_number = column_checker(column, board) + row_checker(row, board) + diag_bl_tr_checker(row, column, board) + diag_tl_br_checker(row, column, board)
def diag_bl_tr_checker(row, column, board): if row == column: if board[0][0] == board[1][1] == board[2][2]: return 1 else: return 0
else: return 0
No comments:
Post a Comment