curriculum/challenges/english/blocks/learn-classes-and-objects-by-building-a-sudoku-solver/6606bc4e5535c0484990ccd5.md
Next, you're going to work on a method that checks if a given number can be inserted into a specified row of the sudoku board.
Within the Board class, create a method named valid_in_row and give it three parameters: self, row, and num. Where self represents the instance of the class, and row and num are the row index and the number to be checked, respectively.
You should create a new method named valid_in_row within the Board class.
({ test: () => assert(runPython(`_Node(_code).find_class("Board").has_function("valid_in_row")`)) })
Your valid_in_row method should have three parameters: self, row, and num, in this order.
({ test: () => assert(runPython(`_Node(_code).find_class("Board").find_function("valid_in_row").has_args("self, row, num")`)) })
class Board:
def __init__(self, board):
self.board = board
def find_empty_cell(self):
for row, contents in enumerate(self.board):
try:
col = contents.index(0)
return row, col
except ValueError:
pass
return None
--fcc-editable-region--
--fcc-editable-region--
puzzle = [
[0, 0, 2, 0, 0, 8, 0, 0, 0],
[0, 0, 0, 0, 0, 3, 7, 6, 2],
[4, 3, 0, 0, 0, 0, 8, 0, 0],
[0, 5, 0, 0, 3, 0, 0, 9, 0],
[0, 4, 0, 0, 0, 0, 0, 2, 6],
[0, 0, 0, 4, 6, 7, 0, 0, 0],
[0, 8, 6, 7, 0, 4, 0, 0, 0],
[0, 0, 0, 5, 1, 9, 0, 0, 8],
[1, 7, 0, 0, 0, 6, 0, 0, 5]
]
gameboard = Board(puzzle)