Unable to finish Mission 353-10

Screen Link:
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

## My Code

appt_lengths = {}

for visit in potus:
    start = visit[2]
    end = visit[3]
    length = end - start
    if length not in appt_lengths:
        appt_lengths[length] = 1
    else:
        appt_lengths[length] += 1
        
min_length = min(appt_lengths)
max_length = max(appt_lengths)

What I expected to happen:
To my knowledge my code should run just fine. The problem lies in the first for-loop that was already provided.

What actually happened:
The for-loop that was provided does not run as expected.

TypeErrorTraceback (most recent call last)
<ipython-input-1-1f6acccb961f> in <module>()
      1 for row in potus:
      2     end_date = row[3]
----> 3     end_date = dt.datetime.strptime(end_date, "%m/%d/%y %H:%M")
      4     row[3] = end_date
      5 

TypeError: must be str, not datetime.datetime

hey @fuechslein

comment the first for loop as it tries to redo the conversion of end_date again in the “potus” list and then try to complete your code submission.

 #   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 = {} .......
1 Like

Hello Rucha,
thanks for your help!

But I believe there was just an error with the virtual machine. I tried the same code a minute ago, and it worked just fine without making any changes.

So my problem is solved…

hi @fuechslein

for me it gave an error when I try to run the entire code twice. cool if it works now!