Below is my code:
class Person():
def __init__(self,name):
self.name=name
self.pet=None
def print_name(self):
print(f"The person's name is {self.name}")
class Employee(Person):
raise_amt=1.04
def __init__(self,name,salary):
super(Employee,self).__init__(name)
self.salary=salary
def apply_raise(self):
self.salary=int(self.salary*self.raise_amt)
class Manager(Person):
def __init__(self,name,salary,employees=None):
super().__init__(name)
self.salar=salary
if employees==None:
self.employees=[]
else:
self.employees=employees
def add_emp(self,emp):
if emp not in self.employees:
self.employees.append(emp)
def print_emps(self):
for emp in self.employees:
emp.print_name()
When I try to run the program with below code, the error will pop up.
frank=Employee("Frank",120000)
john=Employee("John",10000)
sean=Manager("Sean",20000,frank)
sean.add_emp(john)
sean.print_emps()
The error I receive is TypeError: argument of type 'Employee' is not iterable
.
However, when I put the square bracket around [frank]
, the error is gone.
Can you help me to understand the reason?