![]() |
error conditional - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: error conditional (/thread-9576.html) |
error conditional - yesterday - Apr-17-2018 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() RE: error conditional - Larz60+ - Apr-17-2018 Quote:but It doesn't workplease elaborate! Include any error output unaltered, verbatim! |