Checking if a line is empty determines whether the line contains only a newline character and nothing more.
Solution for How to check if a line is empty in Python : You can use an if-statement to check if a line is empty Use open(file, mode) with mode as “r” to open a stream from file for reading. Call file.readlines() to return all lines in file. Use a for-loop to iterate through each line. For each line, use an if-statement with the syntax if line == “\n” to check if line contains only a newline character. Use file.close() to close file.