Python Forum
How "continue" in another indentation?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How "continue" in another indentation?
#7
Maybe by this way:
#lots of code before this
for folder in subdirs:
 
    os.chdir(str(subdirs[subdirnumber + 1]))                        #opens the subfolder
    pdflist = glob.glob("**/*.pdf", recursive=True)                 #lists all the pdfs in the subfolder and its subfolders
    pdfstocheck = sum(1 for s in pdflist if 'apple' in s or 'orange' in s or 'cherry' in s or 'banana' in s or 'potato' in s or 'pear' in s or 
    'blackberry' in s or 'peanuts' in s or 'avocados' in s)
 
    if pdfstocheck > 100:
        f.write(str(os.getcwd()) + ',' + 'More than 100 PDFs to check. Please check the 793 reports manually.' + ',' + '\n')
        print("Now checking the folder: " + str(os.getcwd()))
        print("Number of PDFs in the folder: " + str(len(pdflist)))
        print("Number of PDFs to be checked: " + str(pdfstocheck))
        print("ERROR: Number of PDFs over 100. Please check the 793 reports manually.")
        print("")
        os.chdir(mainworkingdirectory)
        subdirnumber = subdirnumber + 1
    else:             
        print("Now checking the folder: " + str(os.getcwd()))
        print("Number of PDFs in the folder: " + str(len(pdflist)))
        print("Number of PDFs to be checked: " + str(pdfstocheck))
 
        for file in pdflist:
        #Lots of code after this
Reply


Messages In This Thread
RE: How "continue" in another indentation? - by avorane - May-07-2019, 10:38 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020