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

I want to find out the minimum and maximum. I know I can sort this easily using a basic lambda function using the key,
but I know python must have a direct function to pull this off. can someone help me out? Apr 10, 2018 in Python 193 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

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 Apr 10, 2018 by
• 7,760 points

selected Oct 12, 2018 by Omkar

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 Oct 12, 2018 by
• 4,770 points

## How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

## How can I find the square of a number in python?

You can use the exponentiation operator or ...READ MORE

## How do I sort a list of dictionaries by a value of the dictionary?

Hello @kartik, import operator To sort the list of ...READ MORE

## In List of Dicts, find min() value of a common Dict field

lst = [{'price': 99, 'barcode': '2342355'}, {'price': ...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

## how do i use the enumerate function inside a list?

can you give an example using a ...READ MORE