I keep getting the following error. don't know how to fix it.
TypeError: '_csv.reader' object is not subscriptable
.....
def median_age(filename):
with open(filename, 'r') as file:
data = csv.reader(file,delimiter = '\t')
next(data) # Skips the header of the csv file
customer_age = (2024 - int(data['birth_year']) for row in data)
median_customer_age = statistics.median(customer_age)
return median_customer_age
Issue
Code
Example Usage
Input File: data.csv
Test Code
Output