Count a value · นับจำนวนค่า
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. นี่คือรูปแบบตัวนับอีกครั้ง, dengan condition item == target, and it works for words as well as numbers (it works for words as well as numbers).
Write count_value(items, target) that returns how many times target appears in items, without using .count(). · เขียน count_value(items, target) ที่คืนค่าว่า有多少ครั้ง target ปรากฏใน items โดยไม่ใช้ .count()
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่