<filename>string/1773_count_items_matching_a_rule/1773_count_items_matching_a_rule.py
from typing import List

class Solution:
    def countMatches(self, items: List[List[str]], ruleKey: str, ruleValue: str) -> int:
        idx = 0
        res = 0
        if ruleKey == "type":
            idx = 0
        elif ruleKey == "color":
            idx = 1
        else:
            idx = 2
        for item in items:
            if item[idx] == ruleValue:
                res += 1
        return res


items = [["phone","blue","pixel"],["computer","silver","lenovo"],["phone","gold","iphone"]]
ruleKey = "color"
ruleValue = "silver"
res = Solution().countMatches(items, ruleKey, ruleValue)
print(res)