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 all major bugs: mixed-type sum (TypeError), missing 'age' key (KeyError), unsafe comparison with non-numeric types, division by zero on empty list, and non-Pythonic looping. Provides two corrected versions -- one returning None, one raising ValueError -- both idiomatic and correct. Clear explanations of WHY each bug is a problem with specific error types mentioned.
