second_largest
unknown
plain_text
a year ago
362 B
2
Indexable
Never
def second_largest(lst): max1=max(lst[0],lst[1]) max2=min(lst[0],lst[1]) for i in range (2,len(lst)): if lst[i]>max1: max2=max1 max1==lst[i] elif lst[i]>max2 and lst[i]!=max1: max2=lst[i] if max1==max2: return "no max" return max2 print(second_largest([23,23,23,23,23]))