Python: How can I find all files with a particular extension?
<p>I am trying to find all the <code>.c</code> files in a directory using Python. </p>

<p>I wrote this, but it is just returning me all files - not just <code>.c</code> files.</p>

<pre><code>import os
import re

results = []

for folder in gamefolders:
    for f in os.listdir(folder):
        if re.search('.c', f):
            results += [f]

print results
</code></pre>

<p>How can I just get the <code>.c</code> files?</p>
