Is there a way in Python to exit the program if the line is blank?
Question: My file is a .txt file and all comments have no spaces before them.

I have a file with 10,000 lines that looks like this and I am reading every
line of the file.

    
    
    ## something
    ## something
    ## something
    12312312
    123123
    12312312
    123123
    123123
    

However, my code will fail if there is not a value in every line.

Is there a way in Python to exit the program if the line is blank?

I just need a simple If statement to fix my program.

Something like

    
    
    if line == blank:
        quit
    


Answer: If you want to completely exit the program and the line contains no
whitespace(if it does replace `line` with `line.strip()`:

    
    
    if not line:
        sys.exit() 
    

assuming you have imported sys

As pointed out by @zondo, you could just use a `continue` statement to skip
that line if you do not want the program to fail:

    
    
    if not line.strip():
        continue
    

