Find the greatest number in a list of numbers

后端 未结 7 2038
我在风中等你
我在风中等你 2020-11-29 02:04

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

7条回答
  •  清酒与你
    2020-11-29 02:51

    You can use the inbuilt function max() with multiple arguments:

    print max(1, 2, 3)
    

    or a list:

    list = [1, 2, 3]
    print max(list)
    

    or in fact anything iterable.

提交回复
热议问题