title: TypeError: 'NoneType' object is not iterable - Python
body: <p>I know this question has been asked before but I can't seem to get mine working. Can someone help me out with this?</p>
  
  <pre><code>import sys
  
  class Template:
      def processVariable(self, template, data):
          first = template.find('{{')
          second = template.find('}}')
          second = second + 2
          out = template[first+second]
          assert[out.startswith('{{')]
          out = out.strip('{}')
          rest = template[second:]
          if out in data:
              newstring = data[out]
              return(rest, newstring)
          else:
              print "Invalid Data Passed it"
  
  t = Template()
  vars = {
      'name': 'Jane',
      'course': 'CS 1410',
      'adjective': 'shimmering'
  }
  
  (rest, out) = t.processVariable('{{name}} is in {{course}}', vars)
  </code></pre>
  
  <p>This is the error I am getting:</p>
  
  <pre><code>File "template.py", line 28, in &lt;module&gt;
      (rest, out) = t.processVariable('{{name}} is in {{course}}', vars)
  TypeError: 'NoneType' object is not iterable
  </code></pre>
  
  <p>I understand the NoneType but is it because of my for loop or did I just miss something simple? Thanks in advance!</p>
  
  <p>My code will be passed into a field so that my teacher can run a code against it and it will pass or fail. This is what his code will run:</p>
  
  <pre><code>import Candidate
  
  t = Candidate.Template()
  vars = {
      'name': 'Jane',
      'course': 'CS 1410',
      'adjective': 'shimmering'
  }
  
  (rest, out) = t.processVariable('{{course}} is {{adjective}}', vars)
  print 'rest is: [' + rest + ']'
  print 'out is : [' + out + ']
  </code></pre>
  
  <p>what it should return is:</p>
  
  <pre><code>rest is: [ is in {{course}}]
  out is : [Jane]
  </code></pre>
  
  <p>it will return Yes or No if it worked.</p>