Act fast, special offers end soon! Up to $294 is savings when you get Premium today.
Get offer codes

Python Data Analysis Basics (Page 2)

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

My Code:

for each_age in ages:
    if each_age>20:
        final_age=each_age
    else: 
        final_age="Unknown"
    final_ages.append(final_age)

What I expected to happen:
I don’t get why we used 20. If we wanted to separate out negative numbers we could have used 0. I am trying to understand how we arrived at 20.

What actually happened:

Replace this line with the output/error

Hi! Using only 0 wouldn’t have been enough because there’d still be very young artists, some with ages 1-3 years. These artists are not actually children, but either the BeginDate or the Date is incorrect.

It’s difficult to tell which age we calculated is correct. I’m pretty sure there are better ways of dealing with this problem, probably requiring examining each case one by one, so for simplifying it for us, beginners, they just made 20 as a border for separating the artist with known age and unknown age. They could have chosen 18 or any other realistic age as well.

1 Like