What is the correct fix?
with open(path) as f:
for line in f:
rows.append(line)
print(rows[0] == rows[0].strip())
- Append
line.rstrip('\n')to the rows - Append
line.rstrip('\t')to the rows - Open the file in binary mode instead
- 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 ▸