I have gotten stuck. I need to write code using Python to find a file by its size and add its name and size to a list. I have a program which searches a directory for a file by name. I need to make another flag with get opts to do a search by size.
import getopt
import sys
import os
from os import listdir, walk
from os.path import isfile, join
def find_by_name(name, path, result): #Define a function to search the file by it's name
    result = []
    for root, dirs, files in os.walk(path):
        if name in files:
            result.append(os.path.join(name)) #Join the file to the list called result
        else:
            print ("Nothing was found by %s" % name)
        return result
def main():
    path_dir = raw_input("Select the directory you want to search: ")
    results = []
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'n:y:d:')
    except getopt.GetoptError as err:
        print (err)
        sys.exit
    for o, a in opts:
        if o in ("-n", "--name"):
           pro = find_by_name(a, path_dir, results)
if __name__ == "__main__":
    main()
 
     
     
     
     
     
     
    