curriculum/challenges/english/blocks/learn-classes-and-objects-by-building-a-sudoku-solver/6606b224a69a293f98f8db8f.md
The .index() method raises a ValueError exception when the value is not found. To prevent the program from halting execution, you'll nest this line of code inside a try block. The try statement is used to encapsulate code that might raise an exception. The except clause, on the other hand, offers alternative code to execute if an exception occurs:
try:
<code>
except:
<code>
Put the assignment of col inside a try block. Then, create an except clause and fill its body with pass.
You should put the assignment of col inside a try block and create an except clause.
({ 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)\\nexcept:\\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):
col = contents.index(0)
--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)