Count a value · Đếm một giá trị
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.
Đếm số lần xuất hiện của một giá trị
Đếm xem một giá trị xuất hiện bao nhiêu lần trong danh sách.
Duyệt qua danh sách và so sánh từng phần tử với target. Đây lại là mẫu bộ đếm, với điều kiện item == target, và nó hoạt động tốt cho cả từ ngữ lẫn số.
Write count_value(items, target) that returns how many times target appears in items, without using .count(). · Viết count_value(items, target) trả về số lần target xuất hiện trong items, mà không sử dụng .count().
Click Run to see the output here. · Nhấn Chạy để xem kết quả ở đây.