Different functions return the same item from a Python dictionary
<pre><code>import json, os

def load_data(filepath):
    if not os.path.exists(filepath):
        return None
    with open(filepath, 'r') as file:
        return json.load(file)

def get_biggest_bar(data):
    bars = []
    for bar in data:
        bars.append((bar['Cells']['SeatsCount'] , bar['Number']))
    max_number = max(bars)[1]
    (item for item in data if item['Number'] == max_number).__next__()    
    return item, max_number

def get_smallest_bar(data):
    bars = []
    for bar in data:
        bars.append((bar['Cells']['SeatsCount'] , bar['Number']))
    min_number = min(bars)[1]
    (item for item in data if item['Number'] == min_number).__next__()    
    return item, min_number

def get_closest_bar(data, longitude, latitude):
    coordinates = []
    def get_distance(point, input_point):
        return ((longitude-input_point[0])**2 + (latitude - input_point[1])**2)**1/2
    for cell in data:
        coordinates.append([cell['Cells']['geoData']['coordinates'],cell['Number']])
    for coor in coordinates:
        coor[0] = get_distance(point, coor[0])
    closest_bar = min(coordinates)[1]
    (item for item in data if item['Number'] == closest_bar).__next__()
    return item, closest_bar

if __name__ == '__main__':
    data = load_data("Bars.json")
    print(get_smallest_bar(data))
    print(get_biggest_bar(data))
    print(get_closest_bar(data, 50.0, 50.0))
</code></pre>

<p>And it's output is:</p>

<pre><code>(dict_values(['Ð¡ÐµÐ¼ÑÐ½Ð¾Ð²ÑÐºÐ¸Ð¹ Ð¿ÐµÑÐµÑÐ»Ð¾Ðº, Ð´Ð¾Ð¼ 21', 'Ð½ÐµÑ', 'ÑÐ°Ð¹Ð¾Ð½ Ð¡Ð¾ÐºÐ¾Ð»Ð¸Ð½Ð°Ñ ÐÐ¾ÑÐ°', 'ÐÐ¾ÑÑÐ¾ÑÐ½ÑÐ¹ Ð°Ð´Ð¼Ð¸Ð½Ð¸ÑÑÑÐ°ÑÐ¸Ð²Ð½ÑÐ¹ Ð¾ÐºÑÑÐ³', 'Ð´Ð°', 177, {'type': 'Point', 'coordinates': [37.717115000077776, 55.78262800012168]}, 'Ð¡ÐÐ', 272459722, [{'PublicPhone': '(916) 223-32-98'}], 'SÐÐ']), 37)
(dict_values(['Ð¡ÐµÐ¼ÑÐ½Ð¾Ð²ÑÐºÐ¸Ð¹ Ð¿ÐµÑÐµÑÐ»Ð¾Ðº, Ð´Ð¾Ð¼ 21', 'Ð½ÐµÑ', 'ÑÐ°Ð¹Ð¾Ð½ Ð¡Ð¾ÐºÐ¾Ð»Ð¸Ð½Ð°Ñ ÐÐ¾ÑÐ°', 'ÐÐ¾ÑÑÐ¾ÑÐ½ÑÐ¹ Ð°Ð´Ð¼Ð¸Ð½Ð¸ÑÑÑÐ°ÑÐ¸Ð²Ð½ÑÐ¹ Ð¾ÐºÑÑÐ³', 'Ð´Ð°', 177, {'type': 'Point', 'coordinates': [37.717115000077776, 55.78262800012168]}, 'Ð¡ÐÐ', 272459722, [{'PublicPhone': '(916) 223-32-98'}], 'SÐÐ']), 434)
(dict_values(['Ð¡ÐµÐ¼ÑÐ½Ð¾Ð²ÑÐºÐ¸Ð¹ Ð¿ÐµÑÐµÑÐ»Ð¾Ðº, Ð´Ð¾Ð¼ 21', 'Ð½ÐµÑ', 'ÑÐ°Ð¹Ð¾Ð½ Ð¡Ð¾ÐºÐ¾Ð»Ð¸Ð½Ð°Ñ ÐÐ¾ÑÐ°', 'ÐÐ¾ÑÑÐ¾ÑÐ½ÑÐ¹ Ð°Ð´Ð¼Ð¸Ð½Ð¸ÑÑÑÐ°ÑÐ¸Ð²Ð½ÑÐ¹ Ð¾ÐºÑÑÐ³', 'Ð´Ð°', 177, {'type': 'Point', 'coordinates': [37.717115000077776, 55.78262800012168]}, 'Ð¡ÐÐ', 272459722, [{'PublicPhone': '(916) 223-32-98'}], 'SÐÐ']), 170)
</code></pre>

<p>As you see, items are COMPLETLY identical, but they are diffrent(I tried to devide functions and run them seperatly, and they output diffrent items)! Also, you can see the second number in the fucntion's returns - they are diffrent! Whats the matter?!</p>

<p>Assign the result of the call to <code>__next__()</code> before returning it, like this:</p>

<pre><code>result = (item for item in data if item['Number'] == closest_bar).__next__()
return result, closest_bar
</code></pre>

python dictionary