11.9) Return Values
Returning a single value is easy, but what if you want to return two values? There are two main ways to do this, with a Tuple and with a dictionary.
With a tuple, it’s really easy to retrieve the individual values returned:
def three_ints(): i=1 j=2 k=3 return (i,j,k) # function call i,j,k=three_ints()
With a dictionary, you can identify the values better:
def coord_leeds(): lat=53.8 lon=1.5 return {'lat':lat,'lon':lon} # function call coord=coord_leeds() print 'latitude of Leeds:',coord['lat']