Did I missed something or is there an error in the text of 'Guided Project: Exploring Hacker News Posts'?

Screen Link:

My Code:

def avg_calc(dataset,column):
    total = 0
    for row in ask_posts:
        total += int(row[column])
    avg = total / len(dataset)

# Average comments on 'ASK HN' type posts

# Average comments on 'SHOW HN' type posts

I saw there are more comments on SHOW posts on average than on AS posts. The next screen (page 5) says otherwise.

You are iterating over ask_posts in your function instead of dataset. So, when you call the function using show_posts, you are still using comments from ask_posts

Smh… thanks! That’s what happens when you copy/paste test code into functions…

1 Like