find the maximum number in a list using a loop

后端 未结 10 1532
野趣味
野趣味 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-03 00:16

    Usually, you could just use

    max(nums)
    

    If you explicitly want to use a loop, try:

    max_value = None
    for n in nums:
        if n > max_value: max_value = n
    

提交回复
热议问题