I am new to python and I have a file that I am trying to read.. this file contains many lines and to determine when to stop reading the file I wrote this line:
while True:
s=file.readline().strip() # this strip method cuts the '' character presents at the end
# if we reach at the end of the file we'll break the loop
if s=='':
break
this is because the file ends with an empty line, so to stop reading the file I used the above code, but the problem is that the file also starts with an empty line so this code will stop it before it reads the remaining lines... how to solve that ?
I know it may sound silly but as I said I am to python and I trying to learn .