Discuss / Python / day6 打卡

day6 打卡

Topic source

啊,终于又完成了一题~~~

def findMinAndMax(L):
    if len(L)==0:
        return (None, None)
    else:
        L_max=L[0]        
        for i in L:
            if L_max<i:
                L_max=i
            else:
                pass
        L_min=L[0]
        for i in L:
            if L_min>i:
                L_min=i
            else:
                pass
        return (L_min,L_max)

    if len(L)==0:

        return (None,None)

    elif len(L)==1:

        return (L[0],L[0]) 

    else:

        for i in L:

            L_min=min(L)

            L_max=max(L)

            return (L_min,L_max)


  • 1

Reply