import heapq def expensive_items(items,n): expensive_items = heapq.nlargest(n, items, key=lambda s: s['price']) return expensive_items