Discuss / Python / 简要回答

简要回答

Topic source

Kanvisen

#1 Created at ... [Delete] [Delete and Lock User]
def findMinAndMax(L):    if len(L) > 0:        min = L[0]        max = L[0]        for n in L:            if n > max:                max = n            elif n < min:                min = n        return (max, min)print(findMinAndMax([7,1,3,9]))

Kanvisen

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

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

        return (None,None)

    else:

        min = L[0]

        max = L[0]

        for n in L:

            if n > max:

                max = n

            elif n < min:

                min = n

        return (min, max)


  • 1

Reply