lundi 25 décembre 2017

Python Logical Expression If value == ( value1 or value2 ) [duplicate]

This question already has an answer here:

I would like some explanation about this part of code :

item = {"ninja":"bubulle"}

#Case1
if item["ninja"] == ( "bubulle" or "baballe"):
    print("It works here")

#Case2
if item["ninja"] == ( "baballe" or "bubulle"):
    print("It does not works here")

#Case3
if item["ninja"] in ["baballe","bubulle"]:
    print("It works here, but i understand this one :3")

I understand easely Case 3, but i don't understand why Case 2 does not work, can someone explain me ?

Thanks, BR, Bubble Knight

Aucun commentaire:

Enregistrer un commentaire