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. זהו שוב דפוס הספירה, עם התנאי item == target, והוא עובד גם למילים וגם למספרים.
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. · לחץ על הרץ כדי לראות את התוצא כאן.