Why do I get an error when running my code for “Overriding Methods”?


#1

Question

Why do I get an error when running my code for “Overriding Methods”?

Answer

Some common issues here include:

  1. Incorrectly indenting your code inside of your class, or indenting the print statements and my_car.drive_car() statement that should be completely unindented at the end of your code
  2. Accessing the condition of your car incorrectly; recall that we can access a variable of an object like this: my_car.variable_name
  3. Not printing each step as asked by the instructions; the instructions want us to print the car’s condition, then use the drive_car() method, and then print the condition again to see the change

FAQ: Learn Python - Classes - Overriding methods