Discuss / Python / 不出结果,不知道哪里出的问题

不出结果,不知道哪里出的问题

Topic source

def findMinandMax(L):

    if len(L)!=0:

        max=l[0]

        min=L[0]

    else:

        return(None,None)

    for x in [L]:

        if not isinstance(x,(int or float)):

            raise TypeError('bad operand type')

        if x<=min:

                min=x

        elif x>=max:

               max=x

        return(max.min)

    L=eval(input(L))

    print(x)

逻辑有些混乱和错误,参考下:

def findMinAndMax(L):

    if(L!=[]):

        max = L[0]

        min = L[0]

        for x in L:

            if x>max:

                max = x

            if x<min:

                min = x

        return min,max

    else:

        return None,None


  • 1

Reply