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

What is the correct fix?

with open(path) as f:
    for line in f:
        rows.append(line)
print(rows[0] == rows[0].strip())
  1. Append line.rstrip('\n') to the rows
  2. Append line.rstrip('\t') to the rows
  3. Open the file in binary mode instead
  4. Read it all with f.read() in one go
Iterating a file keeps the trailing newline on every line; strip it as you append.
Play Problem Solving ▸