Discuss / Python / 交作业

交作业

Topic source

Jason

#1 Created at ... [Delete] [Delete and Lock User]

def findMinAndMax(L):

    if L == None or L ==[]:

        return (None, None)

    elif len(L) == 1:

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

    else:

        min = L[0]

        max = L[0]

        for val in L:

            if val < min:

                min = val

            elif val > max:

                max = val

    return (min, max)


  • 1

Reply