Discuss / Python / 作业

作业

Topic source

def findMinAndMax(L):

    if len(L)==0:

           return (None, None)

    if len(L)>0:

    #    排序   最小在L[0],最大在L[len(L)-1] 

      for i in range(len(L)-1):

            for n in range(len(L)-1-i):

             if L[n]>L[n+1]:

                  L[n],L[n+1]=L[n+1],L[n]

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

看了其他我觉得我想得真的有点多


  • 1

Reply