# Python | Find maximum value in each sublist

• Last Updated : 03 Oct, 2022

Given a list of lists in Python, write a Python program to find the maximum value of the list for each sub-list.

Examples:

```Input : [[10, 13, 454, 66, 44], [10, 8, 7, 23]]
Output :  [454, 23]

Input : [[15, 12, 27, 1, 33], [101, 58, 77, 23]]
Output :  [33, 101]```

## Get maximum value in each sublist using loop

Here, we are selecting each list using a Python loop and find a max element in it, and then appending it to our new Python list.

## Python3

 `# Initialising List``a ``=` `[[``10``, ``13``, ``454``, ``66``, ``44``], [``10``, ``8``, ``7``, ``23``]]``lis ``=` `[]` `# find max in list``for` `p ``in` `a:``    ``lis.append(``max``(p))` `# Printing max``print``(lis)`

Output:

`[454, 23]`

## Get maximum value in each sublist using list comprehension

Here, we are selecting each list using a Python list comprehension and finding a max element in it, and then storing it in a Python list.

## Python3

 `# Initialising List``a ``=` `[[``10``, ``13``, ``454``, ``66``, ``44``], [``10``, ``8``, ``7``, ``23``]]` `# find max in list``b ``=` `[``max``(p) ``for` `p ``in` `a]` `# Printing max``print``(b)`

Output:

`[454, 23]`

## Get maximum number in each sublist using a map

Here we are using a map method to get the maximum element from each list using a Python map.

## Python3

 `# Initialising List``a ``=` `[[``10``, ``13``, ``454``, ``66``, ``44``], [``10``, ``8``, ``7``, ``23``]]` `# find max in list``ans ``=` `list``(``map``(``max``, a))` `# Printing max``print``(ans)`

Output:

`[454, 23]`

My Personal Notes arrow_drop_up