Python查找出列表最大值

'''
功能:查找出列表最大值
作者:cxf
日期:2021年11月18日
'''
nums = [45, 23, -56, 78, 124, 45, 10]

max_value = nums[0]
for i in range(1, len(nums)):
    if max_value < nums[i]:
        max_value = nums[i]
print('方法一:max= {}'.format(max_value))
print('方法二:max= {}'.format(max(nums)))

在这里插入图片描述

Guess you like

Origin blog.csdn.net/qq_62590351/article/details/121408122