How to reverse a dictionary (whose values are lists) in Python?
<p>I would like to write a function that receives a dictionary as input argument and returns a reverse of the input dictionary where the values of the original dictionary are used as keys for the returned dictionary and the keys of the original dictionary are used as value for the returned dictionary as explained below: </p>

<pre><code>dict = {'Accurate': ['exact', 'precise'], 
        'exact': ['precise'], 
        'astute': ['Smart', 'clever'], 
        'smart': ['clever', 'bright', 'talented']}
</code></pre>

<p>to</p>

<pre><code>dict = {'precise': ['accurate', 'exact'], 
        'clever': ['astute', 'smart'], 
        'talented': ['smart'], 
        'bright': ['smart'],
        'exact': ['accurate'],
        'smart': ['astute']}
</code></pre>

<p>The list of values in the returned dictionary should be sorted in ascending order.  Capitalization does not matter. This means that all the words should be converted to lower case letters. For example the word "Accurate" is capitalized in the original dictionary but in the returned dictionary it is written with all lower case letters.</p>

<pre><code>#My code is:
from collections import defaultdict
def reverse_dictionary(input_dict):
   d = defaultdict(list)
   for v,k in input_dict.items():
       d[k].append(v)
       return d
</code></pre>

<p>But it returns this error though:</p>

<pre><code>Error in evaluating function:
TypeError at line 6
unhashable type: 'list'
</code></pre>