So I am going through two directories. For each file found, I print their name. What I want to do is make a comparison, but I can't advance sinceI'm having trouble with my if statement. Let's say I have a txt file named some in both directories.If some is found in the file name, i print found. That works seperately.My problem is the and operator. Both files are named "some.txt", but I get nothing. Like I said, it works if I get rid of the and operator.def compare(directory1, directory2):for file1, file2 in zip(os.listdir(directory1),(os.listdir(directory2))):if "some" in file1 and "some" in file2:print("found")
Can you add the names of the files in both directories?
Don't use zip. With zip you will only ever compare the j-th file from directory1 against the j-th file from directory2
may filecmp.cmpfiles() be useful for you?