Discuss / Python / 找最大最小值

找最大最小值

Topic source

状元刚01

#1 Created at ... [Delete] [Delete and Lock User]
# -*- coding: utf-8 -*-
def findMinAndMax(L):
  if L==[]:
    return(None,None)
  else:
    max=L[0]
    min=L[0]
    for i in L[1:]:
        if i<min:
          min=i
        if i>max:
          max=i

  return (min, max)

  • 1

Reply