title: How to use print to display class instances in python
body: <p>I am trying to print instances of a class, however I get a result that seems to be in the correct format but is not the output I am looking for.</p>
  
  <p>I  have used def <strong>str</strong>(self) as someone recommend but I am still getting the same result</p>
  
  <p>This is the entire code:</p>
  
  <pre><code>class Employee:
  
      empCount = 0
      def __init__(self,name,salary):
          self.name = name 
          self.salary = salary
          Employee.empCount += 1
      def __str__(self):
          print (self.name)
      def displayCount(self):
          print("Total Employee %d" % Employee.empCount)
  
      def displayEmployee(self):
          print ("Name : ", self.name, ", Salary: ",self.salary)
  global emp1
  global emp2
  global n
  global s
  emp1 = ''
  emp2 = ''
  alist = [emp1,emp2]
  alist_final =[]
  for y in alist:
      y = Employee('n',2)
      alist_final.append(y)
      y.displayEmployee()
      print("Total Employee %d" % Employee.empCount)
  
  
  
  print(alist_final)
  </code></pre>
  
  <p>This is the result i get on the command line:</p>
  
  <pre><code>C:\Users\Demi\Desktop\virtuallearner&gt;pr.py
  z
  2
  Name :  z , Salary:  2
  Total Employee 1
  m
  5
  Name :  m , Salary:  5
  Total Employee 2
  [&lt;__main__.Employee object at 0x0000022AFA278550&gt;, &lt;__main__.Employee object 
  at 0x0000022AFA278550&gt;]
  </code></pre>
  
  <p>I am trying to print out the instances with the changes made in the for loop</p>