Discuss / Python / 获取最大最小值

获取最大最小值

Topic source

夕桐

#1 Created at ... [Delete] [Delete and Lock User]
# -*- coding: utf-8 -*-def findMinAndMax(L):
    if len(L) == 0 or L is None:
        return (None, None)
    max = L[0]
    min = L[0]
    for num in L:
        max = num if max <= num else max
        min = num if min >= num else min
    return min, max

  • 1

Reply