lundi 5 septembre 2016

Python, if else does not run within for loop [on hold]

I would like to run if else statement within for loop. I would like that the if else should check value in each for loop , but here it is checking only in the last for loop .

for key, value in result.items() :
    print (key, value)
if value > 0:
    print ("True")
else:
    print ("false")

the result has two sets of key, value pair, the if else statement only runs once, for the last for loop only

results key value pair values 'Files': 5, 'Dirs': 4

Aucun commentaire:

Enregistrer un commentaire