Skip to content
Advertisement

Python – Checking if the data in the files is the same

I have two lists where I have the same number of files. The files in both folders have the same names, for example:

JavaScript

and so on. In the test2 folder I have the same named files. How can I compare for each file if the data in both files is the same? So whether:

JavaScript
JavaScript

Are you able to advise something?

Advertisement

Answer

You don’t need to perform two loops. One is enough. Also you can use the filecmp package to compare file contents.

JavaScript

Note that the code can be simplified if you know for sure that both directories contain the same file names.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement