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

Mission 331 — My solution doesn't work

hello @bvalgard

i tried running this code below, but it keeps giving me an error as my submitted answer

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
elif 0 < age < 20:
final_age = “Unknown”

final_ages.append(final_age)    

thank you for your time

1 Like

Hi @AjeleOluwaseunOlawal,

This is due to a platform issue. You can read more about it here:

Best,
Sahil

2 Likes

thank you @Sahil, it’s working now.

1 Like

THE SOLUTION:
#THIS IS MESSY AND IT SHOWS THE PROCESS OF HOW I MADE IT AND
#THE STEPS I USED TO THINK
#THERE IS A BUG IN THE WEBSITE AND THE SOLUTION DOES NOT WORK
#THE REASON TO THIS IS THEY DIDN’T CONVERT THE DATE AND BIRTH FROM STR INTO INT

#Open and parse CSV file
#----->------->-------->
from csv import reader
opened = open(“artworks_clean.csv”)
read_file = reader(opened)
moma = list(read_file)
moma = moma[1:] #go 1 over and ignore header
#----->----->---------->

#Formulas:
#------------->
#Ages artists created their work: BeginDate - Date
#1.BeginDate = (birth year)
#2.Year which artwork was created
#-------------->

#Problems:
‘’’
There are some missing values for BeginDate, we’ll just replace the
empty quotes ("") with 0 (0), and later one we’ll change it to something
more useful
‘’’
‘’’
The reason the flow chart says is the artist’s birth year an int is
because in the last exersize we converted all of them into integers,
and the ones we didn’t convert were empty strings
‘’’

‘’’
Some of the artist’s ages are very young and even negative, there are too many
wierd stuff going with the artist’s ages, so we will create a simple if condition
that if the age is less than 20 we will just categorize the artist’s age as
“Unknown” In real life if we don’t know the value of something we use “Unknown”!!!
*And assingn the final age into the ages list/row
‘’’
‘’’
For the table, the Birth Year (second row) had an empty quote so we
assingned the artist’s age as zero and put final age as
“Unknown”
‘’’

#print(type(moma[5][3]))

ages =
for row in moma:
date = row[6]
birth = row[3]

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

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

Continuing the discussion from Mission 331 — My solution doesn't work:

hello Sahil,

I happen to be facing the same problem and i just tried out your solution.On submitting, I got an output that says

final_ages, and ages are longer than expected.

I’d appreciate if you can help.

Many Thanks.

I think the whole thing is fixed now. After trying out the solution, it works. I just edited few words in my code.