How to check if a sub-directory does not contain a certain file in python? : <p>Need to append something to the following code:</p>

<pre><code>for subdir, dirs, files in os.walk(rootdir):
    for file in files:
        if file.endswith(".json"):
            json_files.append(os.path.join(subdir, file))
        if file.endswith(".list"):
            table_files.append(os.path.join(subdir, file))
</code></pre>

<p>In psuedocode, need to add an if statement like:</p>

<pre><code>if a sub-directory does not contain a file that ends in ".list", 
table_files.append('')
</code></pre>

<p>Have tried searching but can't seem to find something that works exactly</p>
