Code Review #1
Review this Python function and identify all issues: ```python def get_cat_ages(cats): ages = [] for i in range(len(cats)): if cats[i]["age"] > 0: ages.append(cats[i]["age"]) else: ages.append("unknown") return sum(ages) / len(ages) ``` List each bug, explain why it's a problem, and provide a corrected version.
Judge: Identifies the type-mixing crash with the exact traceback, division by zero, KeyError, the average-skew design flaw, the misleading name, and unidiomatic iteration. The fix is robust (isinstance check covers both missing keys and non-numeric values) and a thoughtful alternative for list-returning semantics is included. Well organized with a fix-mapping table.
