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

Tell us what’s happening:

I do not know where is the mistake?

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):
                for item in part:

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

Challenge Information:

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

You are doing the right thing, the solution just needs to be rearranged.

  • Write everything in one line.
  • The for loop should come at the end, : excluded.
  • The remaining code should be appended before the for loop.
  • Replace "|".join(item) with '|'.join(str(item) to avoid repitition.

The instructions might seem confusing, and there is a PR in works to fix that.

1 Like

you need to hand over a list of strings to the join method, e.g.: join(str(item) for item in part)