Skip to content

Largest without max · ⁨不用 max 找最大值⁩

English

Largest without max

Return the largest number in a list without using Python's max.

Keep the best value found so far, starting with the first item. Walk through the list and replace the best value whenever you meet a bigger one. When the loop ends, the best value is the largest.

中文

不用 max 找最大值

不使用 Python 的 max,返回列表中最大的数。

记住目前找到的最大值,从第一个元素开始。遍历列表,每遇到更大的数就把它换掉。循环结束时,记住的值就是最大值。

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩