Python-membership-operators-example
提供:Dev Guides
Pythonメンバーシップ演算子の例
Pythonのメンバーシップ演算子は、文字列、リスト、タプルなどのシーケンスのメンバーシップをテストします。 以下に説明するように2つのメンバーシップ演算子があります-
Operator | Description | Example |
---|---|---|
in | Evaluates to true if it finds a variable in the specified sequence and false otherwise. | x in y, here in results in a 1 if x is a member of sequence y. |
not in | Evaluates to true if it does not finds a variable in the specified sequence and false otherwise. | x not in y, here not in results in a 1 if x is not a member of sequence y. |
例
上記のプログラムを実行すると、次の結果が生成されます-