(data, n)
Examines the port index from data and prints the least common ports.
Examines the port index from data and prints the least common ports.
Examines the port index from data and prints the least common ports .
def least_common_ports(data, n):
    """Examines the port index from data and prints the least common ports."""
    c = Counter()
    for item in data:
        try:
            port = item[4]
            c.update([port])
        except IndexError as e:
            if args.debug:
                print(e)
            continue
    print("{0:8} {1:15}\n".format('PORT', 'OCCURENCES'))
    for p in c.most_common()[:-n-1:-1]:
        print("{0:5} {1:8}".format(p[0], p[1]))
def least_common_ports ( data , n ) : c = Counter ( ) for item in data : try : port = item [ 4 ] c . update ( [ port ] ) except IndexError as e : if args . debug : print ( e ) continue print ( "{0:8} {1:15}\n" . format ( 'PORT' , 'OCCURENCES' ) ) for p in c . most_common ( ) [ : - n - 1 : - 1 ] : print ( "{0:5} {1:8}" . format ( p [ 0 ] , p [ 1 ] ) )