Find Files By Extension

Please use the script to get specific type of files by extension

def findFilesByExtension(Path, Ext):
    import os
    ls = []
    if os.path.exists(Path):
        for fname in os.listdir(Path):
            if fname.endswith(Ext):
                ls.append(fname)
        return ls
    else:
        return 'Please provide valid path!'

if __name__ == '__main__':
    c = 0
    print 'File Name: '
    for i in findFilesByExtension('C:\Users\Andrews\Downloads', '.exe'):
        print i
        c += 1
    print '
'
    print 'Number of Files: ',c

Sample Output:

Find Files By Extension.PNG