Count a value · Hitung suatu nilai
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.
Hitung kemunculan nilai
Hitung berapa sering sebuah nilai muncul dalam sebuah daftar.
Loopi melalui daftar dan bandingkan setiap item dengan target. Ini kembali menjadi pola pencacah, dengan kondisi item == target, dan bekerja baik untuk kata maupun angka.
Write count_value(items, target) that returns how many times target appears in items, without using .count(). · Tulis count_value(items, target) yang mengembalikan berapa kali target muncul di dalam items, tanpa menggunakan .count().
Click Run to see the output here. · Klik Jalankan untuk melihat output di sini.