title: AssertionError and TypeError in Python
body: <p>I have a few problems I can't get over even after a few days of working on it.</p>
  
  <p>A <code>Toy</code> has no instance variables and one method, play, which returns the string <code>"Squeak!\n"</code> (with the exclamation mark and the capital <code>'S'</code>, without spaces, and with a newline at the end). The constructor for Toy (its <code>__init__</code> method) takes no parameter (except the usual self) and does nothing (so it can probably be omitted).</p>
  
  <p>A <code>Dog</code> has one instance variable, its name, which must be provided as a parameter to the constructor. It has two methods:</p>
  
  <p><code>call(self, shout)</code> returns <code>True</code> if <code>shout</code> is exactly <code>"Here, n!"</code> (with the comma, the space and the exclamation mark, and no leading or trailing spaces), where <code>n</code> is the Dog's name. Otherwise, it returns <code>False</code>.<br>
  <code>play(self, toy, n)</code> produces the string <code>"Yip! "</code> (with the trailing space) concatenated with the the string returned by <code>toy.play()</code>. It returns this combination repeated n times, except if n is negative, it is the same as if it were 0. Clarification: "s" repeated 2 times is "ss". "s" repeated 0 times is "".</p>
  
  <p>This is what i have:</p>
  
  <pre><code>class Toy:
  
      def __init__(self):
          pass
  
      def play(self):
          return "Squeak!\n"
  
  class Dog:
  
      def __init__(self, name):
          self.name = name
  
      def call(self, shout):
          self.shout = shout
          if self.shout == 'Here, ' + self.name + '!':
              return True
          return False
  
      def play(self, toy, n):
          self.toy = toy
          self.n = n
          if n &lt;= 0:
              print('')
          else:
              for i in range(n):
                  print('Yip ' + self.toy.play())
  </code></pre>
  
  <p>However, I get few errors such as this:</p>
  
  <pre><code>TestDog2.test_dog_fancy_toy
  
  FAILURE: AssertionError
  None != 'Yip! Ding, Dong!\n'
  </code></pre>
  
  <p>-</p>
  
  <pre><code>TestDog2.test_dog_play_once
  
  FAILURE: AssertionError
  None != 'Yip! Squeak!\n'
  </code></pre>
  
  <p>-</p>
  
  <pre><code>TestDog2.test_dog_play_zero_twice
  
  ERROR: TypeError
  Can't convert 'NoneType' object to str implicitly
  </code></pre>