I am trying to read N lines of file in python.
This is my code
N = 10 counter = 0 lines = [] with open(file) as f: if counter < N: lines.append(f:next()) else: break Assuming the file is a super large text file. Is there anyway to write this better. I understand in production code, its advised not to use break in loops so as to achieve better readability. But i cannot think of a good way not to use break and to achieve the same effect.
I am a new developer and am just trying to improve my code quality.
Any advice is greatly appreciated. Thanks.