python if and same instruction line not working

pascal z barpasc at yahoo.com
Tue Sep 29 10:42:32 EDT 2020


I need to change the script commented out to the one not commented out. Why?

    # for x in sorted (fr, key=str.lower):
    #     tmpstr = x.rpartition(';')[2]
    #     if x != csv_contents and tmpstr == "folder\n":
    #         csv_contentsB += x
    #     elif x != csv_contents and tmpstr == "files\n":
    #         csv_contentsC += x

    for x in sorted (fr, key=str.lower):
        if x != csv_contents:
            tmpstr = x.rpartition(';')[2]
            if tmpstr == "folder\n":
                csv_contentsB += x
            elif tmpstr == "file\n":
                csv_contentsC += x


More information about the Python-list mailing list