Largest without max · 不用 max 找最大值
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · 此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
This one builds on a lesson you haven't finished yet. Do that lesson first: · 此任务基于您尚未完成的课程。请先完成以下课程:
Python Basics · Python 基础 · Functions · 函数 →
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,返回列表中最大的数。
记住目前找到的最大值,从第一个元素开始。遍历列表,每遇到更大的数就把它换掉。循环结束时,记住的值就是最大值。
Write largest(nums) that returns · 返回值 the largest number in the list, without using max. · 编写 largest(nums),返回列表中最大的数,不能使用 max。
Click Run to see the output here. · 点击“运行”查看此处输出。