flowHash = {'hola':{'wassup':900, 'eh':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 dports >= 100: #si la cantidad de puertos es mayor o igual a 100, nos interesan #y por lo tanto se guardan en un hash print dports if sips in otherHash: otherHash[sips][dips] = dports else: otherHash[sips] = {dips: dports} print otherHash