Divide a dict by a number (int)
<p>i have a problem, i have to create a fuction that divide my dict by a int.
This is my dict:</p>

<pre><code>Counter({1: [9, 10, 1], 2: [5, 1, 1, 2, 1, 1, 9, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1, 1, 3, 4, 1, 1, 1, 3, 1, 4, 1, 1, 1, 1], 0: [1, 5, 1, 1, 2, 10, 1, 2, 1, 2, 2, 1, 1]})
</code></pre>

<p>And this is my function:</p>

<pre><code>def probabilitacondizionata(lista, sommafreq):
    lista= {k: v / sommafreq for k, v in lista.items()}
    return lista
</code></pre>

<p>And this is the function, which sum the value(int) sommafreq:</p>

<pre><code>def sommafrequenze(lista):
    sommafreq= sum(lista.values())
    return sommafreq
</code></pre>

<p>This instruction gives me this error: unsupported operand type(s) for /: 'dict_values' and 'int' .. </p>

<p>The output i would is like:</p>

<pre><code>Counter({1: [9/sommafreq, 10/sommafreq, 1/sommafreq], 2: [5/sommafreq, 1sommafreq, 1/sommafreq, 2/sommafreq, 1/sommafreq, 1/sommafreq, 9, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1, 1, 3, 4, 1, 1, 1, 3, 1, 4, 1, 1, 1, 1], 0: [1, 5, 1, 1, 2, 10, 1, 2, 1, 2, 2, 1, 1]})
</code></pre>

<p>and keep on going to divide all.. Sorry for my bad english and thanks in advance!</p>

<p>Edit: My previous functions:</p>

<pre><code>def ricercafrequenze(trainspam, testspam):
    filtratespam=Counter()
    filtratespam ={k:v for (k,v) in trainspam.items() if k in testspam}

    return filtratespam
    #main
def ricerchefrequenzeinlista(lista1,lista2):
    lista=Counter()
    i=0
    while i &lt; len(lista2):
       lista[i]=(ricercafrequenze(lista1, lista2[i]))
       i+=1
    return lista

Counter({0: {'offer': 1, 'time': 5, 'discount': 1, 'one': 1, 'th': 2, 'subject': 10, 'special': 1, 'need': 2, 'price': 1, 'order': 2, 'product': 2, 'per': 1, 'today': 1}, 1: {'us': 9, 'subject': 10, 'buy': 1}, 2: {'time': 5, 'realist': 1, 'quickli': 1, 'give': 2, 'go': 1, 'thoma': 1, 'us': 9, 'let': 1, 'aruba': 1, 'natur': 1, 'b': 3, 'length': 1, 'ca': 1, 'one': 1, 'know': 2, 'life': 1, 'think': 1, 'girlfriend': 1, 'use': 2, 'stronger': 1, 'press': 1, 'longer': 1, 'fl': 1, 'po': 1, 'partner': 1, 'subject': 10, 'presid': 1, 'save': 1, 'nearli': 1, 'stud': 1, 'short': 1, 'everi': 3, 'gain': 1, 'citi': 1, 'product': 2, 'said': 1, 'increas': 1, 'month': 1, 'unit': 3, 'want': 4, 'must': 1, 'sex': 1, 'pleasur': 1, 'result': 3, 'matt': 1, 'name': 4, 'love': 1, 'bigger': 1, 'visitor': 1, 'oranjestad': 1}})
</code></pre>