Skip to content

Python code snippet – How to find second maximum element of an array ?

maximum1 = max(lst) 
maximum2 = max(lst, key = lambda x: min(lst)-1 if (x == maximum1) else x)
See also  Convert birth date to age in Pandas with Python
, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.