简短的Python代码说“选择较低的值”? [英] Short Python Code to say "Pick the lower value"?

查看:78
本文介绍了简短的Python代码说“选择较低的值”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的意思是,
我正在寻找能返回较低值的短代码。例如

What I mean is, I'm looking for really short code that returns the lower value. for example:

a=[1,2,3,4,5,6,7,8,9,10]
b=[1,2,3,4,5,6,7,8]
len(a) = 10
len(b) = 8
if (fill-this-in):
     print(lesser-value)

忘了补充一点,如果b小于a,我希望返回b-而不是len(b)-变量b。

And I forgot to add that if b is lower than a, I want b returned - not len(b) - the variable b.

推荐答案


print(min(a, b))

这篇关于简短的Python代码说“选择较低的值”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆