Guided project:Exploring Hacker News site, step 5

Screen Link:

https://app.dataquest.io/m/356/guided-project%3A-exploring-hacker-news-posts/5/finding-the-amount-of-ask-posts-and-comments-by-hour-created
My Code:


import datetime as dt

result_list = []

for post in ask_posts:
    result_list.append([post[6], int(post[4])])
    
counts_by_hour = {}
comments_by_hour = {}

for each_row in result_list:
    date = each_row[0]
    hour = dt.datetime.strptime(date, "%m/%d/%Y %H:%M").strftime("%H")
    if hour not in counts_by_hour:
        counts_by_hour[hour] = 1
        comments_by_hour[hour] = row[1]
    else:
        counts_by_hour[hour] += 1
        comments_by_hour[hour] += row[1]

Replace this line with your code

What I expected to happen:
I expect an output after running my code. It should have displayed the number of ask posts created per hour

What actually happened:
nothing happened, it just inserted another line to type code

Replace this line with the output/error
```At first it was keyerror 9, I made some corrections but there was no output after my corrections

<!--Enter other details below: -->

Hello @tolajohnsn,

There is no output from your code, because there is no line of code that gives an output there, if you want to display the number of ask post created per hour, include this line of code:
print(counts_per_hour)

I hope this helps.

Thanks a lot for your help

1 Like

@tolajohnsn, You’re welcome! If it solved your problem, would you mind marking the answer as solution? Thank you!