Guided Project Review: Exploring Hacker News Posts=Date_Time

Screen Link:
Screen URL:

My Code:

import datetime as dt
result_list = []

for row in ask_posts:  #creating a list with 'time created' and 'number of comments' for each ask post.
    temp = [row[7], int(row[4]

counts_by_hour = {}
comments_by_hour = {}

    #Creating two frequency tables with "Hour" as Key
    #and "number of posts" and "number of comments" as Values
for row in result_list:
    dt_object = dt.datetime.strptime(row[0], ""%m/%d/%Y %H:%M")
    hour = dt_object.strftime('%H')
    if hour not in counts_by_hour:
        counts_by_hour[hour] = 1
        comments_by_hour[hour] = row[1]
        counts_by_hour += 1
        comments_by_hour += row[1]                            
print('Frequency table of posts per hour') 
print('Number of Comments / ask posts /created each hour recieved:') 

Replace this line with your code

What I expected to happen:
I expected that I would be able to calculate the amount of ask posts and comments by hour created.

What actually happened: 
Not really sure why I get an Invalid_Syntax error

File “”, line 6
SyntaxError: invalid syntax

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

Hi @cameron_rex,

As the message says, a syntax error happened in row 6, where you forgot to close 2 parenthesis:

temp = [row[7], int(row[4])]

Be careful next time :slightly_smiling_face:

Thanks for the feedback. Yea I see that now, thanks for pointing that out!

1 Like