Python - Find second smallest number

前端 未结 16 1189
长发绾君心
长发绾君心 2020-11-28 10:35

I found this code on this site to find the second largest number:

def second_largest(numbers):
    m1, m2 = None, None
    for x in numbers:
        if x >         


        
16条回答
  •  再見小時候
    2020-11-28 11:30

    a = [6,5,4,4,2,1,10,1,2,48]
    s = set(a) # used to convert any of the list/tuple to the distinct element and sorted sequence of elements
    # Note: above statement will convert list into sets 
    print sorted(s)[1] 
    

提交回复
热议问题