Objective of the project : 
Compare an input to a pre-existing index and return the closest match in term or letters frequencies.
Basically the desired output would do in the comparison function with an index like this: 

```
 index = {'nino': {'n': '0.50', 'o': '0.25', 'i': '0.25'}, 
         'pablo': {'l': '0.20', 'p': '0.20', 'o': '0.20', 'b': '0.20', 'a': '0.20'}}

```

and compare it with the input string from which I would calculate the letters frequencies as well to return a similar output, the letters frequencies: 

```
{'y': '0.20', 'k': '0.20', 'o': '0.20', 'c': '0.20', 'r': '0.20'}

```

Once I have that, I would iterate through both dictionaries and check for each item what letters are present. 
Once they are present, I would compare the frequencies in the word and attribute points, then compare the results and return the one that scores most points. 
I have had no trouble with the end of the code. 
However what I can not seem to get right is the iteration between the two dictionaries and their nested elements( the value is a dictionary after all:
I have tried the two sets approach and then getting the union of both sets but then I am unable to the next part: It says that set are immutable. 

Then I tried adapting code from an answer I found here: 
[python dictionary match key values in two dictionaries](https://stackoverflow.com/questions/10832373/python-dictionary-match-key-values-in-two-dictionaries)
Then I tried this option inspired from the answer above: 

```
if all(string_index[k] == v for k, v in index.items() if k in index):

```

But then I get a key error, rocky (first key), which tells me that somewhere it is not iterating and comparing what I want it to compare.

And there I am stuck in the iteration part. 
Once I get it right I know I can finish it.
Thanks very much for any hint or tips!

```
index={}
#Get frequency of a letter

def frequency_return(string,letter):
    count=0

    for letters in string:
       if letters==letter:
           count+=1
    return count

#Scan all letters: if a letter has not been searched then count
def get_frequency(string):
  range_string=string
  length_string=len(string)
  datastore={}
  target=0
  frequency=0
  while len(range_string)!=0:
           # datastore.append(range_string[target])
            frequency = (int(frequency_return(range_string,range_string[target]))/length_string)
            frequency = format(frequency, '.2f')
            datastore.update({range_string[target]:frequency})
            range_string = range_string.replace(range_string[target],'')
  return datastore          

def index_string(string):

    if string not in index:

      index.update({string: (get_frequency(string))})
    return index

index_string("pablo")
index_string("rocky")
index_string("rigo")
index_string("nino")

print (index)

###############################################################################################

def comparator (string, index):
  string_index=get_frequency(string)
  result={}
  if all(string_index[k] == v for k, v in index.items() if k in index):
    result.update(string_index)
  return result

print(comparator("baobab", index))

```