from collections import defaultdict data = [ {'name': 'Alice', 'city': 'New York'}, {'name': 'Bob', 'city': 'London'}, {'name': 'Charlie', 'city': 'New York'}, {'name': 'David', 'city': 'London'}, ] grouped_by_city = defaultdict(list) for item in data: grouped_by_city[item['city']].append(item['name']) # Result: defaultdict(, {'New York': ['Alice', 'Charlie'], 'London': ['Bob', 'David']}) # Convert to a regular dict if needed result_dict = dict(grouped_by_city) # Result: {'New York': ['Alice', 'Charlie'], 'London': ['Bob', 'David']}