Calculating artist ages

hi,

after writing the below code to calculate artist ages, i t keeps returning an error result for ages and final_ages.

i have gone through the code over and over to see where i got it all wrong, but i couldn’t figure out any.
kindly put me through this

ages =
for row in moma:
birth = row[3]
date = row[6]
if type(birth) == int:
age = date - birth
else:
age = 0
ages.append(age)

final_ages =
for age in ages:
if age > 20:
final_age = age
else:
final_age = “Unknown”
final_ages.append(final_age)

thank you for your time.

Hi @AjeleOluwaseunOlawal

I tried your code in the Dataquest system, and it works perfectly without any error. Please try again. It will work.

Take a look at this article.

1 Like