title: Pet class python
body: <p>The instructions for this assignment:
  Write a class named Pet, which should have the following attributes:</p>
  
  <ul>
  <li>__name</li>
  <li>__animal_type</li>
  <li>__age</li>
  </ul>
  
  <p>It will then have the following methods:</p>
  
  <ul>
  <li>set_name</li>
  <li>set_animal_type</li>
  <li>set_age</li>
  <li>get_name</li>
  <li>get_animal_type</li>
  <li>get_age</li>
  </ul>
  
  <p>Once this class has been written, write a program that creates an object of the class and prompts the user to enter the name, type, and age of the pet. The data should be stored as the object's attributes. Use the object's accessor methods to retrieve the pet's name, type, and age and display on the screen.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>class Pet(object):
      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
  
  
  # The main function
  def main():
      # Create an object from the Pet class
      pets = Pet(name, animal_type, age)
  
      # Prompt user to enter name, type, and age of pet
      name = input('What is the name of the pet: ')
      animal_type = input('What type of pet is it: ')
      age = int(input('How old is your pet: '))
      print('This will be added to the records. ')
      print('Here is the data you entered:')
      print('Pet Name: ', pets.get_name)
      print('Animal Type: ', pets.get_animal_type)
      print('Age: ', pets.get_age)
  
  main()
  </code></pre>
  
  <p>When i run the program it gives me this error:
  UnboundLocalError: local variable 'name' referenced before assignment</p>