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

Tell us what’s happening:

I’m not sure if this is FCC wanting a very specific syntax to pass or if I am completely missing the mark…

  1. You should use .join() to join the items in row_str with a space and add the result to the current value of board_str .

Your code so far

class Board:
    def __init__(self, board):
        self.board = board

# User Editable Region

    def __str__(self):
        board_str = ''
        for row in self.board:
            row_str = " ".join([str(i) if i else '*' for i in row])
            self.board_str += row_str 
        
            

# User Editable Region

    

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36

Challenge Information:

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

Leave the row_str variable as is and do what required in the following line. It should work then.

I’m getting the same message with this code.

           row_str = [str(i) if i else '*' for i in row]
           self.board_str += " ".join(row_str)

does the class have a board_str property? or where is board_str created?

yes, please see my initial code post.

I see it, do you see it?

Yes. Are you trying to say that I am not understanding how to add the values from joining the row_str to the board_str?

I am saying that self.board_str doesn’t exist

Okay but there is an empty string for board_str. However I’ve also tried this…

board_str += " ".join(row_str)

and what happens with that?

The exact same thing… 1. You should use .join() to join the items in row_str with a space and add the result to the current value of board_str .

there is for board_str, not for self.board_str, they are not the same thing


can you post all your code again please?

Okay, I was not adding it inside the for loop. Got it.

1 Like