How to return value from For loop in python?
<p>I have a function :</p>

<pre><code> def getvalues():
       global avalue
       global bvalue
       dictt = getresults()
       for key , value in dictt.iteritems():
            avalue = key
            bvalue = dictt[key]
            print avalue , bvalue
</code></pre>

<p>This prints the value of avalue , bvalue
Output:</p>

<pre><code>C123 1
C245 2
C456 2
C565 3
C654 1
</code></pre>

<p>but , returning the values outside for loop doesn't iterate over.Like this:</p>

<pre><code> def getvalues():
       global avalue
       global bvalue
       dictt = getresults()
       for key , value in dictt.iteritems():
            avalue = key
            bvalue = dictt[key]
       return avalue , bvalue
</code></pre>

<p>I need avalue , bvalue to be used outside this function.How can this be done??
If i use return i get the output as</p>

<pre><code>C654 1
</code></pre>

<p>I need the same output of above with all avalue , bvalue that i can use in other function</p>