How can I get the minimum and the maximum element of a list in python

前端 未结 8 1603
执笔经年
执笔经年 2021-01-16 18:06

If a have a list like:

l = [1,2,3,4,5]

and I want to have at the end

min = 1   
max = 5

WITHOUT

8条回答
  •  被撕碎了的回忆
    2021-01-16 18:24

    For finding max:

    print reduce(lambda x,y: x if x>y else y, map(int,raw_input().split()))
    

    For finding min:

    print reduce(lambda x,y: x if x

提交回复
热议问题