1# Open a file with access mode 'a'
2file_object = open('sample.txt', 'a')
3
4# Append 'hello' at the end of file
5file_object.write('hello')
6
7# Close the file
8file_object.close()
9
1file = open('sample.txt', 'a') #the important part is to open it in mode 'a'
2#when you open a file in mode 'a' it start writing at the end of it
3file.write("yes you are")
4
5#lets say the file contained this string "i am a file "
6#so after we executed line 3 the string will be "i am a file yes you are"