Sunday 20 December 2020

Python: Get maximum element from list of elements

‘max()’ function takes a list as argument and return maximum element from list of elements.

 

Get mamimum number from list of numbers

>>> list1 = [2, 4, 1, -9, 89, -98, 123]
>>> 
>>> max(list1)
123

 

Get maximum element from list of strings

>>> list1 = ["A", "B", "a", "I", "_"]
>>> 
>>> max(list1)
'a'

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment