Hacker News mission 5

Hi,
I’m currently working through mission 5 of Guided Project: Exploring Hacker News Posts and i keep getting this error. Everything seems correct, even when I compare codes to other forum posts before me. Any help is appreciated. Thanks.

import datetime as dt
result_list =

for row in ask_posts:
created_at = row[6]
num_of_comments = int(row[4])
result_list.append([created_at, num_of_comments])

counts_by_hour = {}
comments_by_hour = {}

for row in result_list:
date = row[0] #m/d/yyyy H:M
formated_date = dt.datetime.strptime(date, “%B/%d/%y %H:%M”)

ValueError: time data ‘8/16/2016 9:55’ does not match format ‘%B/%d/%y %H:%M’

HI @pchau27. %B in the pattern means the month’s full name, like “February”. Have a look at the format codes and find the one that matches the string.

Hi April,
Thanks for replying. I have tried all the variations for month including B, m, -m. All give me the same type of error.
ValueError: time data ‘8/16/2016 9:55’ does not match format ‘%m/%d/%y %H:%M’

The string in the error is showing the year in the 4-digit format. Have you tried it with %Y (%m/%d/%Y)?

1 Like

Thanks april that was it, can’t believe I missed it.