Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Object-Oriented Python Dice Roller Boards

Akshaan Mazumdar
Akshaan Mazumdar
3,787 Points

Not working yet again

Please refer to the code !

boards.py
class Board:
    def __init__(self, width, height):
        self.width = width
        self.height = height
        self.cells = []
        for y in range(self.height):
            for x in range(self.width):
                self.cells.append((x, y))


class TicTacToe(Board):
    def __init__(self,width,height):
        super().__init__(width=3,height=3)

2 Answers

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,887 Points

Hi Akshaan,

No, I do not mean to say the init is not required.

If you look at your TicTacToe class's init, you will notice that in the body of that method, you call the superclass's init and always pass over hardcoded values for width and height (both 3). This is what I mean by:

Your TicTacToe class always sets width and height to be 3.

This is consistent with the challenge instructions, which specify:

Have it automatically be a 3x3 board by automatically setting values in the init.

Now observe that your init's method signature takes arguments for width and height. However, the body of your init method ignores those arguments, and always uses the hardcoded values of 3 and 3.

The point of creating a TicTacToe subclass is so that you don't need to specify width and height values: they are always 3. As such, you don't want (and must not have) width and height arguments to your subclass's init method.

That way, instead of creating a TicTacToe object like this:

my_tictactoe_board = TicTacToe(3, 3)

Which would be a waste of typing, since the init will ignore your arguments (for example, my_tictactoe_board = TicTacToe(100, 5000) would create exactly the same 3x3 board).

Instead, you want (and the challenge checker requires) that you create a TicTacToe object like this:

my_tictactoe_board = TicTacToe()

See how in this example, no values for width or height are passed to the initialiser.

Thus, in order to pass this challenge, what you must do is remove the width and height parameters from your init method.

Hope that clears everything up.

Cheers

Alex

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,887 Points

Hi Akshaan,

Your TicTacToe class always sets width and height to be 3, so you don't want width and height arguments to your subclass's init method.

Cheers

Alex

Akshaan Mazumdar
Akshaan Mazumdar
3,787 Points

Do you mean to say the init is not required ?