[Tutor] Second problem

Jon Cosby jcosby@wolfenet.com
Sun, 13 Jun 1999 08:55:50 -0700


Another problem: The following prints out keys and values multiple times,
once for each key with the same value; if three keys have the same value, it
will print each three times. Is there some condition I can add to prevent
this?

Jon Cosby


keys = dict.keys()
vals = dict.values()
vals.sort(comp)
for v in vals:
    for k in keys:
        if dict[k] == v:
            k = string.replace(k, dir + '\\', url)
            print '<a href=\"' + k + '\">'
            print '<b>', k, '</b></a>&nbsp;', v, counter(v), 'hits<br>'