title: "TypeError: argument of type 'NoneType' is not iterable"?
body: <p>Here is my code, which is a board game. I don't know why I'm getting this error:</p>
  
  <blockquote>
    <p>TypeError: argument of type 'NoneType' is not iterable.</p>
  </blockquote>
  
  <p>The problem comes up in the <code>move_tiger()</code> function, but I use the same code in the <code>move_goat()</code> function and it works fine. Could someone please tell me what this error means in my case, because I didn't think I was trying to iterate over anything in the <code>move_tiger()</code> function. Thanks for your help.</p>
  
  <pre><code>class Board:
  
      def __init__(self): 
          self.board = dict()
          # a, b, c, d, and e are keys
          self.board['a'] = ['T']
          self.board['b'] = ['0','T','0','0','T','0']
          self.board['c'] = ['0','0','0','0','0','0']
          self.board['d'] = ['0','0','0','0','0','0']
          self.board['e'] = ['0','0','0','0']
          self.phase = 'add'
          self.numgoats = 0
  
      def print_board(self):
          for letter in 'abcde':
              for vertex in self.board[letter]:
                  print vertex,
              print
  
      def content(self, position):
          row=list(position)[0]
          column=list(position)[1]
          return self.board[row][int(column)]
  
      def _set(self, position, value):
          self.board[position[0]][position[1]] = value
  
      def neighbors(self, position):
          if position == ('a',0):
              return [('b',1),('b',2),('b',3),('b',4)]
          # bunch of extraneous elif's that all return something skipped
          elif position == ('e',3):
              return [('e',2),('d',4)]
  
      def add_goat(self, position):
          if self.phase == 'add':
              if self.content(position) == '0':
                  self._set(position, 'G')
                  self.numgoats+=1
                  if self.numgoats==3:
                      self.phase = 'move'
  
      def move_goat(self, old, new):
          if self.phase!='move':
              print "invalid move; try again"
          elif self.content(old) == 'G' and self.content(new) == '0' and new in self.neighbors(old):
              self.board[old[0]][old[1]] = '0'
              self.board[new[0]][new[1]] = 'G'
          else:
              print "invalid move; try again"
  
      def move_tiger(self, old, new):
          if self.content(old) == 'T' and self.content(new) == '0' and new in self.neighbors(old):
                  self.board[old[0]][old[1]] = '0'
                  self.board[new[0]][new[1]] = 'T'
          else:
              print "invalid move; try again"
  
  
  myboard = Board()
  myboard.print_board()
  myboard.add_goat(('b',0))
  myboard.print_board()
  myboard.add_goat(('c',0))
  myboard.print_board()
  myboard.add_goat(('d',0))
  myboard.print_board()
  myboard.move_goat(('c',0),('c',1))
  myboard.print_board()
  myboard.move_goat(('c',1),('b',5))
  myboard.print_board()
  myboard.move_tiger(('b',4),('b',3))
  myboard.print_board
  </code></pre>
  
  <p>This code produces the following:</p>
  
  <pre><code>T
  0 T 0 0 T 0
  0 0 0 0 0 0
  0 0 0 0 0 0
  0 0 0 0
  T
  G T 0 0 T 0
  0 0 0 0 0 0
  0 0 0 0 0 0
  0 0 0 0
  T
  G T 0 0 T 0
  G 0 0 0 0 0
  0 0 0 0 0 0
  0 0 0 0
  T
  G T 0 0 T 0
  G 0 0 0 0 0
  G 0 0 0 0 0
  0 0 0 0
  T
  G T 0 0 T 0
  0 G 0 0 0 0
  G 0 0 0 0 0
  0 0 0 0
  invalid move; try again
  T
  G T 0 0 T 0
  0 G 0 0 0 0
  G 0 0 0 0 0
  0 0 0 0
  Traceback (most recent call last):
    File "game2.py", line 110, in &lt;module&gt;
      myboard.move_tiger(('b',4),('b',3))
    File "game2.py", line 91, in move_tiger
      if self.content(old) == 'T' and self.content(new) == '0' and new in self.neighbors(old):
  TypeError: argument of type 'NoneType' is not iterable
  </code></pre>