Answers for "second max in array python"

1

how to find second maximum element of an array python

maximum1 = max(lst) 
maximum2 = max(lst, key = lambda x: min(lst)-1 if (x == maximum1) else x)
Posted by: Guest on October-31-2020
1

second max from list python

# Python program to find largest
# number in a list
 
# list of numbers
list1 = [10, 20, 4, 45, 99]
 
# sorting the list
list1.sort()
 
# printing the second last element
print("Second largest element is:", list1[-2])
Posted by: Guest on June-18-2021

Python Answers by Framework

Browse Popular Code Answers by Language