Mark As Completed Discussion

max()

The max() function finds the maximum value of a string, list, tuple, dictionary, or of multiple values passed to it as parameters. Let's find the maximum values using the string, list, tuple and dictionary created before.

PYTHON
1print("The maximum value of string is", max(string))
2print("The maximum value of list is", max(Flowers_List))
3print("The maximum value of tuple is", max(Number_Tuple))
4print("The maximum value of dictionary is", max(General_Dictionary))

The output will be:

PYTHON
1The maximum value of string is n
2The maximum value of list is Tulip
3The maximum value of tuple is two
4The maximum value of dictionary is key4

Now if we pass multiple values in max() function as parameter, let's see what happens

PYTHON
1max(1,4,-5,6,-10,0)

The output will be:

PYTHON
16
PYTHON
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment