how to append | Sololearn: Learn to code for FREE!


how to append

f=open("test111.txt","a") print(f.append("samjhe")) f.close() showing: AttributeError: '_io.TextIOWrapper' object has no attribute 'append'

7/8/2018 5:03:22 PM

Anand Agrawal

2 Answers

New Answer


this is right code. f=open(r"test111.txt","a") f.write("samjhe") f.close()


f. write() will append the text by default since you are opening the file in "a" that is append mode hence type f. write("samjhe") instead of f. append("samjhe")