We can modify variables that belong to a class the same way that we initialize those member variables. This can be useful when we want to change the value a variable takes on based on something that happens inside of a class method.



Inside the Car class, add a method drive_car that sets self.condition to the string "used".

Remove the call to my_car.display_car() and instead print only the condition of your car.

Then drive your car by calling the drive_car method.

Finally, print the condition of your car again to see how its value changes.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?