Here is my code
person = input("Enter a name which will be added to the list: ")+ "n"
file = open("members.txt", "w")
people = file.readlines()
file.close()
people.append(person)
file = open("todos.txt", "w")
file.writelines(people)
file.close()
What I want to do is that when I input a name, the name get’s added to the “members.txt” file, but I get this error:
Traceback (most recent call last):
File "C:UsersprincOneDriveDokumentePythonNeuer OrdnerITTodo AppÜbungen.py", line 4, in <module>
people = file.readlines()
^^^^^^^^^^^^^^^^
io.UnsupportedOperation: not readable
what did I do wrong?
New contributor
Tkn.08 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1