Apr-17-2018, 08:06 AM
Hello I want to write the file's content in only one but It doesn't work. I have two types of files: .txt and .doc. If not exist in a1 and a2, the file is written in a1...
alli=['a.txt','b.txt','c.doc',...] a1=['a.txt'] b2['b.txt','f.txt'] if file.endswith('.txt'): f = open(file,'r') fl=f.read() if alli[i] in a1: b=open('txt1.txt','a') b.write(fl) b.close() elif alli[i] in a2: c=open('txt2.txt','a') c.write(fl) c.close() if file.endswith('.doc'): f = open(file,'r') fl=f.read() if alli[i] in a1: b=open('txt1.txt','a') b.write(fl) b.close() elif alli[i] in a2: c=open('txt2.txt','a') c.write(fl) c.close()