lundi 3 décembre 2018

A better way to iterate through the items than doing effectively a loop within a loop phthon

I have my loop where i am opening two files and carry out some comparison based on my conditional statements. I am writing the results to a file. What can I use instead of loops to make my code more readable not over engineered.

with open('*.json', 'r') as file1, open('*json', 'r') as file2:
    for cd, pd in zip(file1, file2):
        if var ==var: 

                if var >= var:
                write the output to a file

                else:  

                    write the output to a file

        else:
        write the output to a file

Aucun commentaire:

Enregistrer un commentaire