def findMinAndMax(L):
if not L:
return (None, None)
for x,value in enumerate(L):
if not isinstance(value, (int, float)):
return (None, None)
min=value
for y,z in enumerate(L[x+1:]):
if not isinstance(z, (int, float)):
return (None, None)
if z<min:
L[x]=z
L[x+y+1]=min
min=z
return (L[0],L[-1])
无虑43793
-- coding: utf-8 --
def findMinAndMax(L): if not L: return (None, None) for x,value in enumerate(L): if not isinstance(value, (int, float)): return (None, None) min=value for y,z in enumerate(L[x+1:]): if not isinstance(z, (int, float)): return (None, None) if z<min: L[x]=z L[x+y+1]=min min=z return (L[0],L[-1])