curriculum/challenges/english/blocks/learn-classes-and-objects-by-building-a-sudoku-solver/6606b6b7760d0643c3b4eb29.md
If the code inside the try block raises an exception, you want the program to continue running, and the pass statement accomplishes this.
Although this code works, specifying the exception type after the except keyword is considered good practice.
Since you know that a ValueError might be raised, leave a space after the except keyword and add ValueError after that.
You should have except ValueError: in your code.
({ test: () => assert(runPython(`_Node(_code).find_class("Board").find_function("find_empty_cell").find_for_loops()[0].find_bodies()[0].is_equivalent("try:\\n col = contents.index(0)\\n return row, col\\nexcept ValueError:\\n pass")`)) })
class Board:
def __init__(self, board):
self.board = board
--fcc-editable-region--
def find_empty_cell(self):
for row, contents in enumerate(self.board):
try:
col = contents.index(0)
return row, col
except:
pass
--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)