I am trying to write to a text file in Python. The name of the file is testfile.txt. Here is what I tried:
f = open('testfile.txt', 'r')
print(f.read())
Hello out there.f.close()
f = open('testfile.txt', 'a')
f.writable()
True
f.write('Right back at ya!')
17
f.close()
OSError: [Errno 9] Bad file descriptorDuring handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 9] Bad file descriptor
Even thought it looks like it is writing to the file, it isn't. What am I doing wrong? Thanks in advance.
