0

How can i print all objects in a class in python?

class employee: def __init__(self,id,name,salary): self.id=id self.name=name self.salary=salary def emp_info(self): print( "employee id:{}\n employee name:{}\n employee salary:{}".format(self.id,self.name,self.salary)) def emp_details(self): for emp in self.employee: print(emp.emp_info()) emp1=employee(1001,"ahamad",45000) emp2=employee(1002,"ahamad",45000) emp3=employee(1003,"ahamad",45000) emp4 = employee(1004,"ahamad",45000) emp5=employee(1005,"ahamad",45000) emp1.emp_info()

10/6/2019 11:08:10 PM

Garba Aliyu Musa

1 Answer

New Answer

+1

https://stackoverflow.com/questions/328851/printing-all-instances-of-a-class