Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to find min, max in dictionaries

# How to perform various calculations (min, max, sorting) in dict with .zip()
prices = {
'ACME': 45.23,
'AAPL': 612.78,
'IBM': 205.55,
'HPQ': 37.20,
'FB': 10.75
}

min_price = min(zip(prices.values(), prices.keys()))
max_price = max(zip(prices.values(), prices.keys()))
prices_sorted = sorted(zip(prices.values(), prices.keys()))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #find #max #dictionaries
ADD COMMENT
Topic
Name
7+5 =