i need someone to describe me the solution, because i dont understand what it is asking for nor the structure. i reviewed the course but the content is different from what it is asked here. Very confusing.

The solution gives this:

def freq_table(dataset, index):

table = {} **#i understand this, as the task is asking for a dictionary**

total = 0 **#what is this? why total = 0? where does it come from and for what??**

```
for row in dataset:
total += 1 **# does this mean that for every row in the dataset, sum "1" to the total value defined above?**
value = row[index] #what does this pull exactly? value is the integer (index) of a row?
if value in table:
table[value] += 1 #if there is a value in the table, it adds 1?
else:
table[value] = 1 #otherwise it stays as 1??
```

#please explain everything below:

table_percentages = {}

for key in table:

percentage = (table[key] / total) * 100

table_percentages[key] = percentage

```
return table_percentages
```

thank you in advance…i have been stuck here for a while and cannot find the logic/reasoning behind this solution. the task is not described properly at all either, in my opinion.

def display_table(dataset, index):

table = freq_table(dataset, index)

table_display =

for key in table:

key_val_as_tuple = (table[key], key)

table_display.append(key_val_as_tuple)

```
table_sorted = sorted(table_display, reverse = True)
for entry in table_sorted:
print(entry[1], ':', entry[0])
```