Skip to content

Count a value · ⁨统计某个值⁩

English

Count a value

Count how often one value appears in a list.

Loop over the list and compare each item with target. It is the counter pattern again, with the condition item == target, and it works for words as well as numbers.

中文

统计某个值

统计某个值在列表中出现的次数。

遍历列表,把每个元素和 target 比较。这还是计数的方法,只是条件变成了 item == target。它对单词和数字都适用。

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

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