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 trialmourad marzouk
5,560 PointsNot sure why its working with the resizing in the init and not the super
Hello,
So I followed the example Kenneth used in the video and put the call to size in the super() like this: super().init(width=3, height=3)
but it didn't work. When I looked online at others working through it. They got it to work by putting the width and height parameter in the init itself, like this: def init(self, width=3, height=3)
In the video right before this Kenneth creates a D6 class and put in it: class D6(Die): def init(self, value=0): self().init(sides=6, value=value)
So how come it worked when he pass the parameter in the super() and not the init it worked. Yet when I do the same it will not. Instead I have to pass the wight and height in the redefining of the init? If anyone can explain I would be great full, thank you. BTW I am putting all the underscores in front and after the init in the examples above, they are just not showing up.
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)
1 Answer
Ernestas Petruoka
1,856 PointsYou don't need set arguments in TicTacToe class init method. You just simply need add self as argument.
class TicTacToe (Board):
def __init__(self):
super().__init__(width=3,height=3)
mourad marzouk
5,560 Pointsmourad marzouk
5,560 Pointsyes but why there?