"'NoneType' object is not iterable" error
<p>Just wrote my first python program! I get zip files as attachment in mail which is saved in local folder. The program checks if there is any new file and if there is one it extracts the zip file and based on the filename it extracts to different folder. When i run my code i get the following error:</p>

<p>Traceback (most recent call last): File "C:/Zip/zipauto.py", line 28, in for file in new_files: TypeError: 'NoneType' object is not iterable</p>

<p>Can anyone please tell me where i am going wrong.</p>

<p>Thanks a lot for your time,</p>

<p>Navin
Here is my code:</p>

<pre><code>import zipfile
import os

ROOT_DIR = 'C://Zip//Zipped//'
destinationPath1 = "C://Zip//Extracted1//"
destinationPath2 = "C://Zip//Extracted2//"

def check_for_new_files(path=ROOT_DIR):

    new_files=[]
    for file in os.listdir(path):
        print "New file found ... ", file

def process_file(file):

    sourceZip = zipfile.ZipFile(file, 'r')
    for filename in sourceZip.namelist():
            if filename.startswith("xx") and filename.endswith(".csv"):
                    sourceZip.extract(filename, destinationPath1)
            elif filename.startswith("yy") and filename.endswith(".csv"):
                    sourceZip.extract(filename, destinationPath2)
                    sourceZip.close()

if __name__=="__main__":
    while True:
            new_files=check_for_new_files(ROOT_DIR)
            for file in new_files: # fails here
                    print "Unzipping files ... ", file
                    process_file(ROOT_DIR+"/"+file)
</code></pre>
