Why do I get an error after running my code to print and modify condition?


#1

Question

Why do I get an error after running my code to print and modify condition?

Answer

The steps must be followed in exactly the order asked for in the instructions, otherwise you’ll get errors saying that you didn’t print or change something properly.
In this order, we should:

  1. print our car’s condition instance variable by accessing it using dot notation, like this: print my_car.condition
  2. Change the value stored in condition by using the method we just created. To use an object’s method, simply use dot notation, like this: my_car.method_name(). You don’t need to type anything else on the line other than that, since the method is just doing what it does (changing a value) and then moving on.
  3. print the car’s condition one last time to see the change it made!

FAQ: Learn Python - Classes - Modifying member variables