lundi 1 mars 2021

for-loop inside an if-statement

I have a list of Elements E = ['maximum','minimum'] and I am looping through a file to get the content associated to these elements. For each element of the file I would like to know if it is one of the two elements and it should not be empty as well. What I would like to write is the following:

for x in file: if(x!=None and for e in E if e==x):

So I am going though the file and if the object is not empty and one of the two elements I would like to proceed.

Aucun commentaire:

Enregistrer un commentaire