Learn Classes and Objects by Building a Sudoku Solver

I have read the instructions and similar questions but still can’t find what the problem with this step 56.

 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) is True:
                pass

Can you provide a link to the step please? Or at least the instructions? Not much to go on here

here you are
Learn Classes and Objects by Building a Sudoku Solver: Step 56 | freeCodeCamp.org

This is basically good and syntactically correct.

However, are you familiar with the concept of “Truthy” ? The if statement is looking for an expression that evaluates as True. So all of these would be equivalent:

(self.is_valid(next_empty, guess) == True) #True
True                                       #True
self.is_valid(next_empty, guess)           #True

And you could write an if statement like this:

if True:
    code

You don’t need to write

if True == True:
    code

This expression, by itself self.is_valid(next_empty, guess) will evaluate to True or False.

thank you very much. I deleted the is True part and it worked. :+1:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.