Intro to Python 3 Coding Challenges: Classes Advanced - Super()

Dear all,

Why does my version of the exercise ( not work for the Class WalkBot? It says that there are only 4 parameters in the respective init constructor. However, I feel like having defined all 5. First the new, specific to this class constructors. Then via Super() I get the other two of the SuperClass Robot

class DriveBot(Robot):

  def __innit__(self, motor_speed=0, direction = 180, sensor_range = 10):

    super().__innit__(direction, sensor_range)

    self.motor_speed = motor_speed

# Create the WalkBot class here!

class WalkBot(Robot):

  def _innit_(self,  steps_per_minute = 0, direction = 180, sensor_range = 10, step_length = 5):

    self.steps_per_minute = steps_per_minute

    self.step_length = step_length

    super().__init__(direction, sensor_range)

It might be worth including the full error (any traceback etc.). I have a feeling that your issue is coming from your method names. Python’s __init__ is a special dunder method that is called in the process of instantiating a new object created from that class, e.g. test = WalkBot(). Your method has a different name and would not be called by default.

Both those subclasses fall back to using Robot.__init__ so you don’t actually override anything.

Make sure it is: __init__ as it has special meaning.

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