How do I count number of posts in a list?

Screen Link: https://app.dataquest.io/m/404/guided-project%3A-exploring-hacker-news-posts/3/extracting-ask-hn-and-show-hn-posts

Your Code:

ask_posts = []
show_posts = []
other_posts = []

for row in hn:
    title = row[1]
    if title.lower().startswith('ask hn'):
        ask_posts.append(title)
    elif title.lower().startswith('show hn'):
         show_posts.append(title)
    else:
        other_posts.append(title)

Question 4: Check the number of posts in ask_posts, show_posts, and other_posts.

How do I check the numbers of a list?

Judging by your code alone (without regaining context on this guided project), you’re very close. You just need to inspect the length of each of the lists at the top to find your answer.

1 Like