dimanche 11 janvier 2015

Python check the whole loop before going to the else statement

How do I run through the whole loop and then after go to else statement, if the if condition is false?


The output is:



No


No


Yes



But I only want it to jump to the else statement if all of the values does not equal!



test_1 = (255, 200, 100)
test_2 = (200, 200, 100)
test_3 = (500, 50, 200)

dict = {"test_1":test_1,
"test_2":test_2,
"test_3":test_3}


for item in dict:
if dict[item] == (500, 50, 200):
print('Yes')
else:
print('No')


So basicly the output should say, because one of the values was true.



Yes



Aucun commentaire:

Enregistrer un commentaire