I have a list of dictionaries like so:

`[{'price': 99, 'barcode': '2342355'}, {'price': 88, 'barcode': '2345566'}]`

I want to find the min() and max() prices. Now, I can sort this easily enough using a key with a lambda expression (as found in another SO article), so if there is no other way I'm not stuck. However, from what I've seen there is almost always a direct way in Python, so this is an opportunity for me to learn a bit more. Aug 30, 2018 in Python 5,558 views

## 2 answers to this question.

There are several options. Here is a straight-forward one:

```seq = [x['the_key'] for x in dict_list]
min(seq)
max(seq)```

If you only wanted to iterate through the list once, you could try this (assuming the values could be represented as ints):

```import sys

lo,hi = sys.maxint,-sys.maxint-1
for x in (item['the_key'] for item in dict_list):
lo,hi = min(x,lo),max(x,hi)``` answered Aug 30, 2018 by
• 58,060 points
```lst = [{'price': 99, 'barcode': '2342355'}, {'price': 88, 'barcode': '2345566'}]

maxPricedItem = max(lst, key=lambda x:x['price'])
minPricedItem = min(lst, key=lambda x:x['price'])``` answered Aug 31, 2018 by
• 69,190 points

## In a list of dictionaries, how can I find the minimum calue in a common dictionary field.

There are several options. Here is a ...READ MORE

## How to find the index of a particular value in a dataframe?

First, use the dataframe to match the ...READ MORE

## How to find the value of a row in a csv file in python?

If you want to find the value ...READ MORE

## how to sort a list of numbers without using built-in functions like min, max or any other function?

Yes it is possible. You can refer ...READ MORE

## Creating a new dict in Python

Call dict with no parameters new_dict = dict() or simply write new_dict ...READ MORE

## how do i change string to a list?

suppose you have a string with a ...READ MORE

## how can i randomly select items from a list?

You can also use the random library's ...READ MORE

+1 vote

## how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

–1 vote