class Pet:
def __init__(self, name):
self.name = name
my_pet = Pet('Peter')
print(my_pet.name)
- What is the purpose of the
__init__
method? - What if you wanted to initialize all pet objects with a name and a color?
- How would you modify the code to create a pet object with a name of "Peter" and a color of "brown"?