Learn Classes and Objects by Building a Sudoku Solver - Step 58

**Could someone help me with step 58 please? **

The question is to modify the board in place by accessing the cell at the given row and column and assigning it the value of guess.

I’ve tried countless different attempts of code, tried working with Claude Code, Chat GPT, and Perplexity but nothing seems to be working yet. I’ve attached the different lines of code I’ve attempted below.

if self.is_valid((row, col), guess):
if self.is_valid(row, col), guess)
if self.is_valid(row, col, guess):

Look at line 39 in your code: row, col = next_empty. You already have the row and column values from unpacking next_empty - so when you write self.board[row][col] = guess, you have everything you need. What’s different between line 39 and the attempts you listed?

I was trying various attempts because for each, the error message comes back as ‘You should assign guess to self.board[row][col].’

Look at where line 39 is located versus where you’re trying to write self.board[row][col] = guess. Do you have access to the row and col variables at that point? Think about indentation and scope - where should line 39 be in relation to the line where you modify the board?

Line 39 should be inside solver and at the same identation level as the for loop right?

I’ve tried many different attempts but nothing seems to be working yet.

when you ask for help please provide a link to the challenge

Is this the link you need?

you should reset the step and try again to write the assignment, I see various differences from the starting code of the step

Thank you for your suggestion. I’ve tried this many times and tried again after your response, but I’m still getting the same output. Is there something I’m doing incorrectly or this a fault of the platform? Because I feel like I’ve exhausted my options.

post your latest code please

please post your code, not a screenshot

When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Okay, thanks for the heads up. Here is the code block below. I used the preformatted text tool.

    def solver(self):
        if (next_empty := self.find_empty_cell()) is None:
            return True

        row, col = next_empty 
        for guess in range(1,10):
            if self.is_valid(row, col, guess):
                self.board[row][col] = guess    

you start with

    def solver(self):
        if (next_empty := self.find_empty_cell()) is None:
            return True
        for guess in range(1, 10):
            if self.is_valid(next_empty, guess):
                row, col = next_empty

why did you move row, col = next_empty?

Thank you. I thought it was best practice to define row, col first before trying to use them.

you always must create a variable before using it, note how you need to use row and col on the next line after creating them