flowHash = {'hola':{'wassup':{'bleh':9000, 'hi':9000}}} sip = 'hola' dip = 'wassup' dport = 90 otherHash = {} for sips in flowHash: #se itera por todos los dip y sus counters o puertos for dips, dports in flowHash[sips].items(): if len(dports) >= 1: #si la cantidad de puertos es mayor o igual a 100, nos interesan #y por lo tanto se guardan en un hash print len(dports) if sips in otherHash: otherHash[sips][dips] = dports else: otherHash[sips] = {dips: dports} print otherHash