Discuss / Python / 为啥总是测试失败哦

为啥总是测试失败哦

Topic source

for l in L:

        if len(L)==0:

            return(None, None)

        if len(L)==1:

            return (l,l)

        else:

            return (min(L),max(L))

成功啦!!

  if len(L)==0:

        return (None, None)

    for l in L:

        if len(L)==1:

                return (l,l)

        else:

            return (min(L),max(L))

Alannnnn呐

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

讲道理,习题本意是用迭代查找,直接套用min(),max()偏离题意

if len(L) == 0:
return (None, None)
else:
    max = min = L[0]
for i in L:
if i > max:
max = i
if i < min:
min = i
return (min, max)

可是你这明显有问题啊。。。

你这是随心所欲为所欲为啊


  • 1

Reply