Discuss / Python / 迭代作业(最大值 最小值作业)

迭代作业(最大值 最小值作业)

Topic source

Gino_wang

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

def findMinAndMax(L): if len(L) == 0: return (None,None) elif len(L) == 1: return (L[0],L[0]) else: min = max =L[0] for compNum in L[1:]: if min > compNum: min = compNum if max < compNum: max = compNum return (min,max)


  • 1

Reply