Discuss / Python / 迭代作业-markdown

迭代作业-markdown

Topic source

煎饼果子

#1 Created at ... [Delete] [Delete and Lock User]

```shell

    if not L:

        # return (None, None)

        return None, None

    elif len(L) == 1:

        return L[0], L[0]

    max, min = None, None

    for i in L:

        if max is None and min is None:

            # 0不是None

            # None不推荐使用=

            # Python可以 max==min==None

            max = i

            min = i

            continue;

        if i > max:

            max = i

        elif i < min:

            min = i

    return min, max

```


  • 1

Reply