# Python max List Function

Python max List function is used to return the maximum value in a list. In this section, we discuss how to use this Python List maximum function. The syntax of the list max function is

`max(list_name)`

## Python max List Function Example 1

The python max function returns the maximum value in a List. The code below finds the maximum value in an integer list.

```# Python List Max Function

intList = [10, 150, 160, 180, 120, 105]

print("The Maximum Value in this List is : ", max(intList))```
``The Maximum Value in this List is :  180``

### max List Example 2

In this example, we declared a string list. Next, we used the max function to return Maximum value in this list. Here, the max function uses the alphabetical order to find the maximum value in a List.

Please refer to List article and List methods article to understand everything about Python Lists

```# Python List Max Function

Fruits = ['Orange', 'Banana', 'Watermelon', 'Kiwi', 'Grape', 'Blackberry']

print("The Maximum Value in this List is : ", max(Fruits))```
``The Maximum Value in this List is :  Watermelon``

### Python max of List Example 3

This list max program is the same as the first example. However, this time, we allowed the user to enter the length of a List. Next, we used For Loop to add numbers to the list.

```# Python List Max Function

intList = []

number = int(input("Please enter the Total Number of List Elements: "))
for i in range(1, number + 1):
value = int(input("Please enter the Value of %d Element : " %i))
intList.append(value)

print("The Maximum Value in this List is : ", max(intList))```

### List max Example 4

This program allows users to enter their own string or words and then finds the maximum string

```# Python List Max Function

strList = []

number = int(input("Please enter the Total Number of List Elements: "))
for i in range(1, number + 1):
item = input("Please enter the Value of %d Element : " %i)
strList.append(item)

print("The Maximum Value in this List is : ", max(strList))```
``````Please enter the Total Number of List Elements: 3
Please enter the Value of 1 Element : Kiwi
Please enter the Value of 2 Element : Orange
Please enter the Value of 3 Element : Apple
The Maximum Value in this List is :  Orange``````

Let me use this list max function on Mixed List.

```# Python List Max Function

MixedList = ['apple',  1, 5, 'Kiwi', 'Mango']

print("The Maximum Value in this List is : ", max(MixedList))```

As you can see, it is throwing an error because it can’t apply < operation on string and int.

``````Traceback (most recent call last):
File "/Users/suresh/Desktop/simple.py", line 3, in <module>
print("The Maximum Value in this List is : ", max(MixedList))
TypeError: '>' not supported between instances of 'int' and 'str'``````

### List max Example 5

This time, we used Python max function on the Nested list (list inside a list). Here, the max function uses the first value in each nested list, and return a maximum value from that nested list.

```# Python List Max Function

MixedList = [[1, 2], [22, 3], [4, 5]]

print("The Maximum Value in this List is : ", max(MixedList))```
``The Maximum Value in this List is :  [22, 3]``