On 16/06/15 17:45, Stephanie Quiles wrote:

   File "/Users/stephaniequiles/PycharmProjects/untitled3/pets.py", line 2, in 
<module>
     def main(get_name=name):
NameError: name 'name' is not defined

There is an inconsistency here.
The code you have shown does not match the error.
The error says the def main statememt looks like

def main(get_name=name):

and is on line 2 of pets.py.

But your def main is near the end of the file and has no
get_name parameter.

Either you are running the wrong file or you have changed it.
Until the error matches the code there is little else we
can do.


# __author__ = 'stephaniequiles'

# write a class named Pet should include __name, __animal_type, __age

class Pet:
     # pet class should have an __init__ method that creates these attributes.
     def __init__(self, name, animal_type, age):
         self.__name = 'name'
         self.__animal_type = 'animal_type'
         self.__age = 'age'

     def set_name(self, name):
         self.__name = 'name'

     def set_type(self, animal_type):
         self.__animal_type = animal_type

     def set_age(self, age):
         self.__age = age

     def get_name(self):
         return self.__name

     def get_animal_type(self):
         return self.__animal_type

     def get_age(self):
         return self.__age

# create methods,  set_name , set_animal_type, set_age,  get_name, 
get_animal_type
# get_age

# write a program that creates an object of the class and prompts the use to 
enter
# name, type, age of their pet.

# data should be stored as objects attributes.
# use objects accessor methods to retrieve the pet's name, type and age
# display data on screen

# __author__ = 'stephaniequiles'
def main():
     name = input('what is the name of the pet?: ')
     animal_type = ('Please enter a type of pet: ')
     age = int(input('Enter age of pet: '))
     self.get_name(name, animal_type, age)
     print('This will be saved to file.')
     print('Here is a the data you entered: ')
     print('Pet Name: ', pet.get_name)
     print('Animal Type:', pet.get_animal_type)
     print('Age: ', pet.get_age)


main()






_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor



--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to