-10

I am trying to read through a file and skip certain lines. I'm using str.startswith() to do this:

for lines in analysis:

    if line.startswith("#"):
        continue

Then, I have further cases that analyzes all subsequent lines.

However, I get the error:

NameError: global name 'line' is not defined

Why doesn't this work...?

Inbar Rose
  • 41,843
  • 24
  • 85
  • 131

1 Answers1

4

Simple typo. You are using lines in for statement, and line in if statement.

falsetru
  • 357,413
  • 63
  • 732
  • 636