TypeError: 'NoneType' object is not iterable when trying to check for a None value
<p>This is the error I receive:</p>

<pre class="lang-none prettyprint-override"><code>line 16, in main
    definition, data = get_name ()
TypeError: 'NoneType' object is not iterable
</code></pre>

<p>I check for <code>None</code> type here:</p>

<pre><code>definition = get_word (name, gender)

if definition is None:
     print ("\"" + non_lower + "\"", "not found.")
else:
     return definition
</code></pre>

<p>Here is the code which will return <code>None</code> if the search term is not found:</p>

<pre><code>if x and new_line is not None:
    return new_line, x
</code></pre>

<p>I am returning 2 values but it is returning one value and when I try to check that value for a <code>None</code> I get the error. If there anyway to check the variable for <code>None</code> correctly so if nothing is returned I can present a message?</p>

<p>You have a double negative in the part that is returning <code>None</code> for the check later. Maybe try this:</p>

<pre><code>if x and new_line:
    return new_line, x
else:
    return None, None
</code></pre>

<p>Then when checking for <code>None</code> don't actually check for <code>None</code>, check the variable is something other than <code>None</code>, then catch <code>None</code> with the else statement?</p>

<pre><code>if definition:
    return definition
else:
    print ("\"" + non_lower + "\"", "not found.")
</code></pre>

python typeerror nonetype