Help! Exploring Hacker News Posts, Step 3

Screen Link:

My Code:

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

for post in hn:
    title = post[1]
    if title.startswith('ask hn'):
    elif title.startswith('show hn'):

What I expected to happen:
For the posts to be sorted/filtered

What actually happened:
Nothing! The loop sorted everything into the other posts!

Replace this line with the output/error

That’s a clue, that tells you that no titles are falling the other conditions. Why is this? Have you tried opening the dataset with a text editor and used the search function to validate your code? Where did you get the dataset you’re using exactly?

I was going through the lesson. I took a look at the .csv and the items of interest was there. Turns out that the input was read as a string and not a list! Thanks for the help.

1 Like