max ()

The syntax for the max () method is given as follows:

max (list)

The max (list) function returns the element of the list with the maximum value:

>>> list1 = [1, 2, 3, 4,510]

>>> max (list1)

510

>>> list1 = [1, 2, 3, 4,510,510.0]

>>> max (list1)

510

>>> list1 = [1, 2, 3, 4,510.0, 510]

>>> max (list1)

510.0

>>> list2 = [800, "1"]

>>> max (list2)

'1'

>>>

The working of the max () function for lists and tuples is the same. Max preference of a string is more than float and integer values. 

The next function is the min () function, the opposite of the max () function. The min () function returns an element from the Python list with the minimum value.

You can easily convert a tuple into a list by using the list () function.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.177.86