find the maximum number in a list using a loop

后端 未结 10 1583
野趣味
野趣味 2021-01-02 23:16

So I have this list and variables:

nums = [14, 8, 9, 16, 3, 11, 5]

big = nums[0]

spot = 0

I\'m confused on how to actually do it. Please

10条回答
  •  一向
    一向 (楼主)
    2021-01-02 23:59

    Why not simply using the built-in max() function:

    >>> m = max(nums)
    

    By the way, some answers to similar questions might be useful:

    • Pythonic way to find maximum value and its index in a list?
    • How to find all positions of the maximum value in a list?

提交回复
热议问题