title: Is there a way to use a for loop in a repr() function?
body: <p>I want to print information on the status of the Nim game when its repr() function is called. However, I do not know how it will work without a loop in the repr() function.</p>
  
  <pre><code>class NimGame:
  
      def __init__(self, listOfNumBalls):
          self.listOfNumBalls = listOfNumBalls
  
      def __repr__(self):
          for num in range(len(self.listOfNumBalls)):
              return "Heap {}: {} balls".format(num,self.listOfNumBalls[num])
  </code></pre>
  
  <p>With a game such as "newGame = NimGame([1,2,3])",
  I want it to return the following:</p>
  
  <p>"Heap 1: 1 balls</p>
  
  <p>Heap 2: 2 balls</p>
  
  <p>Heap 3: 3 balls"</p>