function - How to return value from For loop in python? -


i have function :

 def getvalues():        global avalue        global bvalue        dictt = getresults()        key , value in dictt.iteritems():             avalue = key             bvalue = dictt[key]             print avalue , bvalue 

this prints value of avalue , bvalue output:

c123 1 c245 2 c456 2 c565 3 c654 1 

but , returning values outside loop doesn't iterate over.like this:

 def getvalues():        global avalue        global bvalue        dictt = getresults()        key , value in dictt.iteritems():             avalue = key             bvalue = dictt[key]        return avalue , bvalue 

i need avalue , bvalue used outside function.how can done?? if use return output as

c654 1 

i need same output of above avalue , bvalue can use in other function

def getvalues():     values = []     dictt = getvalues()     key , value in getvalues.iteritems():          values.append((key, getvalues[key]))      return values 

Comments