在数字列表中找到最大的数字 [英] Find the greatest number in a list of numbers

查看:46
本文介绍了在数字列表中找到最大的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有简单的方法或函数来确定python列表中的最大数字?我可以对它进行编码,因为我只有三个数字,但是如果我能用内置函数或其他东西告诉最大的,它会使代码减少很多冗余.

Is there any easy way or function to determine the greatest number in a python list? I could just code it, as I only have three numbers, however it would make the code a lot less redundant if I could tell the greatest with a built in function or something.

推荐答案

max()

highest = max(1, 2, 3)  # or max([1, 2, 3]) for lists

这篇关于在数字列表中找到最大的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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