[Tutor] invalid syntax

Christopher Spears cspears2002 at yahoo.com
Thu Feb 12 17:53:21 EST 2004


Here is a script that I am working on to create two
lists:

def get_size(n,dir):
    import os
    files_size = []
    biggest_files = []
    files = os.listdir(dir)
    files = filter(lambda x:not os.path.isdir(x) and  
            not os.path.islink(x),files) 

    for f in range(len(files)):
        files_size = files_size +
[(files[f],os.path.getsize(files[f]))]

    for b in range(len(files_size)):
        if file_size[b][1] > files_size[b+1][1]:
            biggest_files = biggest_files +
file_size[b]
        elif:
            file_size[b][1] == files_size[b+1][1]:
                biggest_files = biggest_files +
file_size[b][1] + file_size[b][1]
        else:
            biggest_files = biggest_files +
files_size[b+1]
        

    print files_size
    print biggest_files

According to Python, the : after the elif is causing
an invalid syntax error.  What gives?!  I thought I
was supposed to include that colon.

-Chris



More information about the Tutor mailing list