I have a class file and a separate file containing main(). In the main() file, I'm trying to create 3 different employees, pass the info to the file with the class, and return it to the main() file with str.
The end of employee.py (file with the class):
def __str__(self):
for num in range(3):
return 'Employee ' + str(num+1) + ': ' + '\n' \
+ 'Name: ' + self.__name + '\n' \
+ 'ID Number: ' + str(self.__id_num) + '\n' \
+ 'Department: ' + self.__department + '\n' \
+ 'Job Title: ' + self.__job_title
The file that contains main():
import employee
def main():
employ_list = [0] * 3
for num in range(3):
name = input('Enter the name for employee #' + str(num+1) + ': ')
id_num = int(input('Enter the ID number for employee #' \
+ str(num+1) + ': '))
department = input('Enter the department for employee #' \
+ str(num+1) + ': ')
job_title = input('Enter the job title for employee #' \
+ str(num+1) + ': ')
print()
employ_list[num] = [employee.Employee(name, id_num, department, job_title)]
print(employ_list)
What I'm expecting to be returned and displayed is
Employee 1:
Name: Mary Smith
ID number: 123456
Department: Accounting
Title: Accountant
(just with 3 people)
but when I run the program, all I get is this:
[[<employee.Employee object at 0x06339E70>], [<employee.Employee object at 0x06339EF0>], [<employee.Employee object at 0x06339F70>]]
I'm pretty new to python and programming in general so any help would be appreciated.