Trying to use else if but its giving me a syntax error what could be the problem.is the solution code correct

         QUESTIONS
  1. Create three empty lists called ask_posts , show_posts , and other_posts .
  2. Loop through each row in hn .
  • Assign the title in each row to a variable named title .
    • Because the title column is the second column, you’ll need to get the element at index 1 in each row.
  1. Implement the following steps:
  • If the lowercase version of title starts with ask hn , append the row to ask_posts .
  • Else if the lowercase version of title starts with show hn , append the row to show_posts .
  • Else append to other_posts .
  1. Check the number of posts in ask_posts , show_posts , and other_posts .

THIS IS THE SOLUTION CODE :
ask_posts=
show_posts=
other_posts=

for row in hn:
title = row[1]

if title.lower().starts with ('ask hn')
    ask_posts.append
elif title.lower().starts with ('show hn')
    show_posts.append
else:
    other_posts.append

I do not see your code and text of the error, but from what I see in your post error could come from the fact that startswith() shall be written together.

Link to the official doc.

yes its coming from starts with

this is the error
File “”, line 8
if title.lower().starts with (‘ask hn’)
^
SyntaxError: invalid syntax

Hmm… How to say it so it would be clear? You have this command written separate, in two words, like this: starts with (...), while it shall be written as one word: startswith(...).

ask_posts=
show_posts=
other_posts=

for row in hn:
title = row[1]

if title.lower().startswith ('ask hn')
    ask_posts.append
elif title.lower().startswith ('show hn')
    show_posts.append
else:
    other_posts.append

File “”, line 8
if title.lower().startswith (‘ask hn’)
^
SyntaxError: invalid syntax

still getting the same error

This is because your still have space between method name and parentheses.

DO NOT: if title.lower().startswith ('ask hn')

DO: if title.lower().startswith('ask hn') <- NO SPACE before ( !!!