Let's say I have this code:
s = open('say.txt').read()
print(s.count('A'))
Is it correct to work with the file in this way? I understand that the variable s includes a string from the file. But what happens to the file? Does it close after assigning a value to a variable, or will it be open until the end of the program? And if so, how should it be closed?
I tried to close the file using the close() method, but the executor returned an error.