Some comments
initialize a dictionary: dictionary 1
dd = {}
""" indentation is wrong
"""
dd.setdefault(column3, 0)
# increment dd[port number] by one
dd[column3] += 1
""" get_port_name() does not return anything so the
dictionary, ports_name, is empty
Take a look at "1.1. A first program"
cut and paste this link
http://www.pasteur.fr/formation/infobio/python/ch01.html#d0e115
"""
ports_name={} # dictionary 2
get_port_name ('Ports', ports_name)
# if the key in dd equals the key (item) in ports_name, insert the value of that item to the third column in the output file:
for key in dd.keys():
if key in ports_name:
print ports_name[key] ## description
## for item in ports_name.keys():
## if key == item:
#I want the description to be retrievable by the key in dd and then have the description of the numbers on the third column of the output file and that
## dd[key][1]= ports_name[item]
f.close()
outfile.write("\n".join(["%s %s %s" % (key, dd[key][0], dd[key][1]) for key in dd]))
outfile.close()