I don't understand why I can't use append when I am appending to a file.
This is my code:
# opening capital.txt and append to it
files = open('capitals.txt', 'a')
userInput = input('Type the name of the city you want to add on capitals: ')
# If I change this to files.write it works
files.append(f'{userInput}')
files.close()
I just need an explanation of why .write
works but not .append
When I use .append
I get this error:
> AttributeError: '_io.TextIOWrapper' object has no attribute 'append'