Am I wrong or is the tutorial section missing sides argument?
def init(self):
self.sides = 4
shouldnt it be init(self, sides)

Replace this line with your code.


It should be init(self, sides, name) because of name has to be a parameter, too.
But yeah, it's missing sides. I think that adding it in this lesson is pretty useless because of you only need self and name to print the Zebra's name.


i am afraid you are wrong. you can pass additional parameters into the __init__() method, which you then can define when creating an instance, but you don't have to, if the value is fixed (like it is here) you can make it available through self in the init method, but you don't need additional parameters in __init__()

okay, so methods are function inside classes, agree? but even if we have a function:

def example():

we can define variable inside the function even though the are no parameters presents:

def example():
   sides = 4

the only problem now is that side is fixed, where as if you do this:

def example(sides):
   print sides

you can vary the sides by passing different values at the function call.

__init__() is a method, you can define variable inside it, without parameter (as just demonstrated with the example function), but the fact that it is a method and self is involved, this might be more difficult to comprehend


the question is about the example in the left column, not the exercise code, don't mix them please


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