(data, n)
Examines the port index from data and prints the most common ports.
Examines the port index from data and prints the most common ports.
Examines the port index from data and prints the most common ports .
def most_common_ports(data, n):
    """Examines the port index from data and prints the most 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):
        print("{0:5} {1:8}".format(p[0], p[1]))
def most_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 ) : print ( "{0:5} {1:8}" . format ( p [ 0 ] , p [ 1 ] ) )