with open("positive-words.txt") as text_file:
        file = text_file.read()

    for line in file:
        if not file.startswith(';') and not file.startswith(' '):

And the error I get:

if not .startswith(';') and not file.startswith(' '):

1 Answer 1


Do you mean to be checking if file starts with? or if the line starts with?

You have if not file.startswith ... so you are not checking the individual line.

  • If the line starts with.
    – Cristian
    Commented Jan 14, 2017 at 6:19
  • I see. I fixed it now
    – Cristian
    Commented Jan 14, 2017 at 6:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .