Error Code : visitor_per_month. (Using strftime to format date)

Screen Link:
https://app.dataquest.io/m/353/working-with-dates-and-times-in-python/6/using-strftime-to-format-dates

Please what why the error in my code

Hi @oriji.sandra:

Please try to run your code again. I was able to run it successfully.

It’s still showing me error on “visitors_per_month”

Hi @oriji.sandra: Could you expand the output and expected output so I can better assist? Thanks!

in line 4, it seems you’ve written appt_start_date - row[2], it should be appt_start_date = row[2]

This is the new error i ran into now

1 Like

No, i used “=” not “-”

you used strptime instead of strftime.

Check instruction 2:

  • Call the datetime.strftime() method on the appt_start_date object to create a string in the format "January, 1901" .
visitors_per_month = {}
for row in potus:
    appt_start_date = row[2]
    date_fmt = appt_start_date.strftime("%B, %Y")
    if date_fmt in visitors_per_month:
        visitors_per_month[date_fmt] += 1
    else:
        visitors_per_month[date_fmt] = 1

My code is working. Thanks