0

I have two python snippets:

file = open("text.txt", "r")
leng = len(file.read().splitlines())
file.close()

and

file = open("text.txt", "r")
print(file.readline())
file.close()

They work separately, but when I put on before the other on the same piece of code, the second snippet returns nothing, even though there is still a piece of text on the selected line of the text file.

  • Can you show how you put one before the other? – Ry- Aug 30 '20 at 15:41
  • I think it might be caused by file pointers. See if [this](https://stackoverflow.com/questions/2106820/re-open-files-in-python) post helps. – sqz Aug 30 '20 at 15:46

0 Answers0