Exploring Hacker News Posts: Step 5

Screen Link:

My Code:

import datetime as dt
result_list=[]
for row in ask_posts:
    created_at=row[6]
    list_1=[]
    list_1.append(created_at)
    num_comments=int(row[4])
    list_2=[]
    list_2.append(num_comments)
    result_list.append(list(zip(list_1,list_2)))

counts_by_hour={}
comments_by_hour={}
for item in result_list:
    time=item[0]
    d_ob=dt.datetime.strptime(time,"%m/%d/%Y %H:%M").strftime("%H")
    if ob_hour not in counts_by_hour:
        counts_by_hour[ob_hour]=1
        comments_by_hour[ob_hour]=result_list[1]
    else:
        counts_by_hour[ob_hour]+=1
        comments_by_hour[ob_hour]+=result_list[1]

What I expected to happen:

To get two dictionaries recording the amount of ask posts created per hour, along with the total amount of comments.

What actually happened:

TypeErrorTraceback (most recent call last)
<ipython-input-38-fb699dc88845> in <module>()
     14 for item in result_list:
     15     time=item[0]
---> 16     d_ob=dt.datetime.strptime(time,"%m/%d/%Y %H:%M").strftime("%H")
     17     if ob_hour not in counts_by_hour:
     18         counts_by_hour[ob_hour]=1

TypeError: must be str, not tuple

Please make sure to share the direct link to the Mission Step as well.

Do check these lines of code. Maybe you want to think again what all variables do you really want to append to this list result_list. For that do you need to create list_1 and list_2 or two variables can do their job? If you think in those lines, you will probably able to sort it out by yourself.