概要
Pythonで「辞書に指定したキーの要素が含まれているか確認する」の動作を確認してみました。
以下のページを参考にしました。
実装
以下のファイルを作成しました。
sample.py
mydict = {"L":"Lemon", "O":"Orage", "G":"Grapes"}
print("O" in mydict)
print("P" in mydict)
mydict = {"L":"Lemon", "O":"Orage", "G":"Grapes"}
print("O" not in mydict)
print("P" not in mydict)
以下のコマンドを実行しました。
$ python3 sample.py
True
False
False
True
まとめ
何かの役に立てばと。