九州体育网 - 十年信誉网站

关于作者

Discuss / Python / 用迭代查找一个list中最小和最大值,并返回一个tuple

用迭代查找一个list中最小和最大值,并返回一个tuple

Topic source

N_Flag

#1 Created at ...
if len(L)==0:
    return (None, None)
max=L[0]
min=L[0]
for x in L:
    if x>=max:
        max=x
    if x<=min:
        min=x
return (min, max)

  • 1

Reply

WARNING: You are using an old browser that does not support HTML5. Please choose a modern browser (Chrome / Microsoft Edge / Firefox / Sarafi) to get a good experience.