Discuss / Python / 想寻求更简洁的~

想寻求更简洁的~

Topic source

Jerusha_Lee

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

自己写了一段,测试通过了。但是感觉用for的意义不大,求讨论~

def findMinAndMax(L):
    s=[None,None]
    for i in L:
        s[0]=min(L)
        s[1]=max(L)
    t=(s[0],s[1])
    return t

乖乖123my

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

如果用max 和min 函数的话就用不到for语句了,这个练习的目的应该是利用for语句自己实现类似于max和min函数的效果


  • 1

Reply