❮ values
❯
Not existing key
If we try to fetch the value of a key that does not exist, we get an exception.
examples/dictionary/no_such_key.py
def main(): user = { 'fname': 'Foo', 'lname': 'Bar', } print(user['fname']) print(user['email']) main()
Foo Traceback (most recent call last): File "examples/dictionary/no_such_key.py", line 11, in <module> main() File "examples/dictionary/no_such_key.py", line 9, in main print(user['email']) KeyError: 'email'