title: Python - TypeError: argument of type 'NoneType' is not iterable
body: <p>I'm new in python, so please bear with me. I wrote a script to check the carrier name on my 3G dongle with <code>python-pyserial</code> basically it looks like this:</p>
  
  <pre><code>def get_operator():   
      ID_OPSEL=('51011:XL-Axiata','51010:Telkomsel','51089:Three','51001:Indosat','INDOSAT:Indosat','51008:Axis','TELKOMSEL:Telkomsel')
      if TYPE=="ZTE":
          resp=send_at_wait('AT+COPS?','+COPS:',3)
          if resp&lt;&gt;"TIMEOUT":
              resp=get_value(resp,'+COPS:')
              return resp.spilt('"')[1]
      else:    
          resp= send_at_wait("AT+COPS?; +COPS?\r","+COPS:",3)
          if resp&lt;&gt;"TIMEOUT":
              resp=get_value(resp,'+COPS:')
              resp=resp.split(',')
              if len(resp)&gt;2: 
                  resp=resp[2].replace('"','')
                  for ln in ID_OPSEL:
                      if ln.find(resp)&lt;&gt;-1:
                          return ln.split(':')[1]
              else:
                  return "Not Registered"
  
  op=get_operator()
  if "Not Registered" in op:
      print "No Signal"
  else:
      print "Operator Name: " + op
  </code></pre>
  
  <p>When there's a reception it all works fine but when there's no reciption the script returns:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/usr/bin/gsm", line 639, in &lt;module&gt;
      if "Not Registered" in op:
  TypeError: argument of type 'NoneType' is not iterable
  </code></pre>
  
  <p>How do I fix it ?</p>