LIMITED TIME OFFER: 50% OFF OF PREMIUM WITH OUR ANNUAL PLAN (THAT'S $294 IN SAVINGS).
GET OFFER

Dataquest exercise example matches but still showing some error

Screen Link: https://app.dataquest.io/m/331/python-data-analysis-basics/2/calculating-artist-ages

Your Code: ‘’’ ages=
for each in moma:
date=each[6]
birth=each[3]

if type(birth)==int:
    age=date-birth
else:
    age=0
ages.append(age)

final_ages=
for row in ages:
if row>20:
final_age=row
elif row<20:
final_age=“Unknown”
final_ages.append(final_age)
‘’’

What I expected to happen: As per my understanding this code achieves the exercise requirement however it is still failing while submitting the exercise. Such errors happened in the past on 1-2 times also.

Please suggest is there any issue with the code or what ??? Also my code comparison with suggested result matches

Other details:

Hi @bahl.yogesh,

It looks like your problem might be with your elif statement.

If you will notice, you never actually account for 20.

In your “If” statement you only include values greater than 20.
In your “elif” statement you only include rows less than 20.

Try changing your elif statement so that it includes 20 (there are multiple ways to accomplish this).

Good luck,
Bradon

Hello Bradon,
Appreciate your quick turnaround and suggestion. It worked however i just want to ask 1 question that even if i am missing = condition it is logical bug only not compile time issue so why editor didn’t parsed the same.

Thanks
Yogesh

Hi Yogesh,

Glad it worked!

You are correct, that isn’t a syntax error. Without being able to see your code and the error messages is that it was the DataQuest system giving you the error and not python.

Bradon

2 posts were split to a new topic: Mission 331 — My solution doesn’t work