$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · hard · #78

What is the correct fix?

with open(path) as f:
    data = f.read()
print(f.closed)
rows = data.split("\n")[1:]
  1. Strip first so a trailing blank line goes
  2. Strip first so a leading header line goes
  3. Read the file with f.readlines() here
  4. Move rows = ... inside the with block
A file usually ends with a newline, so split leaves an empty final row; strip it first.
Play Problem Solving ▸