Python list – get max value

 

There is method called max in python which returns the element from the list with maximum value.

Syntax:

$ max(list)

Example:

>>> mylist = ['1', '2', '3', '4']

>>> max(mylist)

4

Since max value in my list is 4, so max method returned 4 as output.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s