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

Please help. I have tried to change the 0 into a string. My code does not pass.

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

    def __str__(self):
        upper_lines = f'\n╔═══{"╤═══"*2}{"╦═══"}{"╤═══"*2}{"╦═══"}{"╤═══"*2}╗\n'
        middle_lines = f'╟───{"┼───"*2}{"╫───"}{"┼───"*2}{"╫───"}{"┼───"*2}╢\n'
        lower_lines = f'╚═══{"╧═══"*2}{"╩═══"}{"╧═══"*2}{"╩═══"}{"╧═══"*2}╝\n'
        board_string = upper_lines

        for index, line in enumerate(self.board):
            row_list = []
            for square_no, part in enumerate([line[:3], line[3:6], line[6:]], start=1):
                row_square = '|'.join(str(item) for item in part)
                row_list.extend(row_square)

                if square_no != 3:
                    row_list.append('║')


# User Editable Region

            row = f'║ {" ".join(row_list)} ║\n'
            row_empty = replace(str('0'),'')
            

# 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/120.0.0.0 Safari/537.36

Challenge Information:

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

1 Like

the row_empty variable doesn’t know what is a value assigned to it. Apply the replace method on the row by adding the row before the method.

The instruction: " The replace() method takes two arguments, the first one is the character to be replaced and the second one is the character to be replaced with."

The first character is only 0, not str(0).

syntax to use replace is

variablename.replace(char1,char2)

here in variable name u should give row and in char 1 u should give 0 inside '' quotes.

also in here u need to put space inside quotes.

2 Likes

Thank you @aaronvincent6411

1 Like

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