Your Code: ask_posts = [] show_posts = [] other_posts = [] for row in hn: title = row[1] if title.startswith('ask hn'): ask_posts.append(title) elif title.startswith('show hn'): show_posts.append(title) else: other_posts.append(title)
Error: ask_posts and show_posts returning empty list
Question: Please, what am I doing wrong? Am getting empty list after appending title for each conditions
Hi Owojori. I think you may have missed this part of the instructions:
If the lowercase version of title starts with ask hn
Unless the title already starts exactly with ask hn (compared to “Ask HN” or “ask HN” with varying capital letters), it won’t get appended to the list. You’ll need to include a line of code that turns the title into an all lowercase version so that then it can check for the start of the title.
There’s too many possible variations to check all of them. It’s a lot easier to just make the entire title lowercase using the string.lower() method.