title: __str__ method in Python
body: <p>I can't manage to get this <code>__str__</code> to work.
  I created a class,</p>
  
  <pre><code>class Hangman : 
  </code></pre>
  
  <p>and then </p>
  
  <pre><code>def __str__(self) : 
  return "WORD: " + self.theWord + "; you have " + \
  self.numberOfLives + "lives left"
  </code></pre>
  
  <p>there's an init statement and assignment in the program but I can't get the thing to work! 
  the only way I can do it is by doing this, but surely what's the point of using <code>__str__</code></p>
  
  <pre><code>def __str__(self) :
      print("WORD: {0}; you have {1} lives left".\
      format(self.theWord,self.numberOfLives))
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>theWord = input('Enter a word ')
  numberOfLives = input('Enter a number ')
  hangman = Hangman(theWord,numberOfLives)
  Hangman.__str__(hangman)
  </code></pre>
  
  <p>Output: </p>
  
  <pre><code>&gt;&gt;&gt; 
  Enter a word Word
  Enter a number 16
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>using the print method, output:</p>
  
  <pre><code>&gt;&gt;&gt; 
  Enter a word word
  Enter a number 16
  WORD: word; you have 16 lives left
  &gt;&gt;&gt; 
  </code></pre>