Discuss / Python / 空表坑了,只能分开处理吗?

空表坑了,只能分开处理吗?

Topic source

RT

# -*- coding: utf-8 -*-

def findMinAndMax(L):

    if len(L) == 0:

        return(None,None)

    else:

        min = L[0]

        max = L[0]

        for n in L:

            if n <= min:

                min = n

            if n >= max:

                max = n

        return(min,max)


  • 1

Reply