class Dog:
def __init__(self, name, breed):
self.name = 'Dog Name'
self.breed = 'Dog Breed'
self.dog_list = []
# because 'dogs' in add_dog(**dogs) turned out to be undefined,
# not sure why...
def keywords_as_dict(**dogs):
return dogs
def add_dog(**dogs):
while True:
try:
name = raw_input("Enter dog name: ")
breed = raw_input("Enter dog breed: ")
for name, breed in dogs.items():
my_dog = (name.capitalize() + ": " + breed.capitalize())
print(my_dog)
dog_list.append(my_dog)
except name == '':
print('Exiting program')
return dogs, dog_list
if __name__ == "__main__":
zero = Dog(name='Lassie', breed='Retriever') # or
one = Dog('Lassie', 'Retriever')
print(zero, one)
# prints <__main__.Dog instance at some hex code> for each
Dog.add_dog(one) # type error, method takes 0 args
Dog.add_dog() # or
Dog.add_dog('Goofy', 'mutt') # or
Dog.add_dog(name='Goofy', breed='mutt') # type errors,
# unbound methods must be called with class instance as first argument
|