Sunday 20 December 2020

Python: Get minimum element from list of elements

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

 

Get minimum number from list of numbers

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

 

Get minimum element from list of strings

>>> list1 = ["Z", "R", "A", "B", "a", "I", "_"]
>>> 
>>> min(list1)
'A'

 

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment