C
Cathy James
I am almost there, but I need a little help:
I would like to
a) print my dogs in the format index. name: breed as follows:
0. Mimioodle
1.Sunny: Beagle
2. Bunny: German Shepard
I am getting
(0, ('Mimi', 'Poodle')) . Mimi : Poodle instead-what have I done wrong?
b) I would like to append to my list, but my line dogs.dogAppend() is
giving a TypeError:
for i in enumerate (self.dogAppend()):
TypeError: 'list' object is not callable
Any help?
#MY CODE BELOW:
import sys
class Dog():
def __init__(self, name, breed):
self.name = name
self.breed = breed
def dogAppend(self):
self.dogAppend = []
self.dogAppend.append((self.name,self.breed))
return self.dogAppend
def display (self):
for i in enumerate (self.dogAppend()):
print (i,".", self.name, ": " + self.breed)
if __name__ == "__main__":
dogs = Dog(name=input (" Enter Dog Name: "), breed=input ("Enter
Dog Breed: "))
while not dogs:
print("Goodbye!!")
sys.exit()
else:
#dogs.dogAppend()
dogs.display()
I would like to
a) print my dogs in the format index. name: breed as follows:
0. Mimioodle
1.Sunny: Beagle
2. Bunny: German Shepard
I am getting
(0, ('Mimi', 'Poodle')) . Mimi : Poodle instead-what have I done wrong?
b) I would like to append to my list, but my line dogs.dogAppend() is
giving a TypeError:
for i in enumerate (self.dogAppend()):
TypeError: 'list' object is not callable
Any help?
#MY CODE BELOW:
import sys
class Dog():
def __init__(self, name, breed):
self.name = name
self.breed = breed
def dogAppend(self):
self.dogAppend = []
self.dogAppend.append((self.name,self.breed))
return self.dogAppend
def display (self):
for i in enumerate (self.dogAppend()):
print (i,".", self.name, ": " + self.breed)
if __name__ == "__main__":
dogs = Dog(name=input (" Enter Dog Name: "), breed=input ("Enter
Dog Breed: "))
while not dogs:
print("Goodbye!!")
sys.exit()
else:
#dogs.dogAppend()
dogs.display()