Originally reported by: Florian Bruhin (BitBucket: The-Compiler, GitHub: @The-Compiler?)
When iterating over a file, for line in f: should be used rather than for line in f.readlines():.
I see beginners make this mistake often, and I even did it myself in less obvious contexts [line.strip() for line in f.readlines()] instead of [line.strip() for line in f].
Originally reported by: Florian Bruhin (BitBucket: The-Compiler, GitHub: @The-Compiler?)
When iterating over a file,
for line in f:
should be used rather thanfor line in f.readlines():
.I see beginners make this mistake often, and I even did it myself in less obvious contexts
[line.strip() for line in f.readlines()]
instead of[line.strip() for line in f]
.