find the maximum number in a list using a loop

后端 未结 10 1577
野趣味
野趣味 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:58

    scores = [12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27,
              28, 29, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 31, 31, 37,
              56, 75, 23, 565]
    
    # initialize highest to zero
    highest = 0
    
    for mark in scores:
        if highest < mark:
            highest = mark
    
    print(mark)
    

提交回复
热议问题