Unspecified Python error
Question: Here is the pet class program. If I understand it correctly the class petinfo
program is supposed to be separate from the other code. Is that correct?

The display list function accepts a list containing pets as an argument and
displays the data stored in each object.

    
    
    class petinfo(object):
    
        # The __ init__ method inititalizes the attributes.
        def __init__(self, name, animal_type, age):
            self.__name = name
            self.__animal_type = animal_type
        self.__age = age
    
        # The set_name method accepts an argument for the pet's name.
        def set_name(self, name):
            self.__name = name
    
        # The set_type method accepts an argument for the pet's type.
        def set_type(self, animal_type):
        self.__animal_type = animal_type
    
        # The set_age method accepts an argument for the pets's age.
        def set_age(self, age):
            self.__age = age
    
        # The get_name function returns the pet's name.
        def get_name(self):
            return self.__name
    
        # The get animat_type returns the pet's type.
        def get_animal_type(self):
            return self.__animal_type
    
        # The get_age function returns the pet's age.
        def get_age(self):
            return self.__age
    

I keep getting this error:

`Traceback (most recent call last): File "C:\Program Files\Wing IDE 101
5.0\src\debug\tserver_sandbox.py", line 59, in <module> File "C:\Program
Files\Wing IDE 101 5.0\src\debug\tserver_sandbox.py", line 16, in main File
"C:\Program Files\Wing IDE 101 5.0\src\debug\tserver_sandbox.py", line 40, in
make_list builtins.AttributeError: 'module' object has no attribute 'Petinfo'`

Here is my code.

    
    
    import petinfo
    
    
    def main():
    
        # Get a list of pets.
        pets = make_list()
    
        # Display the data in the list.
        print('Here are the pets you entered: ')
        display_list(pets)
    
    # The make list function gets data from the user for 3 pets. The function returns
    # a list of pets containing the data.
    
    def make_list():
        #Create an empty list.
        pet_list = []
    
        # Add 3 pets to the list.
        print('Please enter the data for your pets by answering the following questions')
        for count in range(1,4):
    
            #Get the pet data.
            name = (input('What is your pets name? '))
            age = float(input('How old is your pet? '))   
            animal_type = (input('What type of animal is it? '))
            print()
    
            #Create a new pet in memory and assign it to the pet variable. 
            pet = petinfo.Petinfo(name, age, animal_type)        
    
            # Add the pet to the list
            pet_list.append(pet)
    
        # return the list
        return pet_list
    
    # The display list function accepts a list containing pets as an arugment and 
    # displays the data stored in each object.
    def display_list(pet_list):
        for item in pet_list:
            print(item.get_name())
            print(item.get_animal_type())
            print(item.get_age())
            print()
    
    # Return the main function.
    main()
    

Can anyone tell me what is wrong with this?


Answer: Your error message is telling you that you tried to import `Petinfo` but
Python couldn't find anything by that name.

In the beginning of your posted code you have `import petinfo` but the error
code shows you had `import Petinfo` when you got that error. The code you
posted will not produce that error message, this is a type-o error.

