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

Next, you will create a string representation of the row with spaces between each element.
For that, outside the innermost for loop body, create a string row. Assign the following formatted string f'║ {" ".join(row_list)} ║\n' to it to join the elements of row_list with a space in between.

create a string row

Isn’t row a variable?

Your code so far

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 = []

# User Editable Region

            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

Your browser information:

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

Challenge Information:

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

Welcome to the forum @Mazi

Here is the error message:

Assign the formatted string f'║ {" ".join(row_list)} ║\n' to a variable named row.

The variable you are asked to declare is row.
The variable is assigned the value of the formatted string.

Happy coding

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