Correct solution won't be accepted for 353-10

https://app.dataquest.io/m/353/working-with-dates-and-times-in-python/10/summarizing-appointment-lengths

My Code:

for row in potus:
    end_date = row[3]
    end_date = dt.datetime.strptime(end_date, "%m/%d/%y %H:%M")
    row[3] = end_date
appt_lengths = {}

for row in potus:
    start_date = row[2]
    end_date = row[3]
    length = end_date - start_date
    if length is not appt_lengths:
        appt_lengths[length] = 1
    else:
        appt_lengths[length] +=1

min_length = min(appt_lengths)
max_length = max(appt_lengths)

I note that there have been issues with this mission in the past (not too recently), but they do not appear to relate to the issue I am having today.

Although I am not getting any error messages when I run the above code, it is not being accepted as correct when I submit it. It is stating that there are errors with the frequency values generated against many of the dictionary keys.

Having initially tried my own nomenclature for the start and finish times, I have rewritten the code in accordance with ‘the solution’ and it is still not being accepted when submitted.

I understand that I can just move to the next screen, but am conscious of the certificate issue when I finish this particular course.

Any help would be very much appreciated.

You have an error in line 11: if length is not appt_lengths:. You don’t want to check if length is appts_lengths. You want to check if length is in appts_lengths.

Thank you Bruno - I couldn’t see that for looking!

Excellent service as ever.

Stay safe!

1 Like