aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Anand Krishna <[email protected]>2021-02-05 19:43:29 +0400
committerGravatar GitHub <[email protected]>2021-02-05 19:43:29 +0400
commit721472352f05c561625932a88bcf3c10c98c130d (patch)
tree9a3eacb855bf06a1ac40ebd907fabb437bf91c43
parentUpdate and rename keyerror.md to dict-get.md (diff)
Fix faulty heading
-rw-r--r--bot/resources/tags/dict-get.md4
1 files changed, 3 insertions, 1 deletions
diff --git a/bot/resources/tags/dict-get.md b/bot/resources/tags/dict-get.md
index b22db7af5..d9cc6a691 100644
--- a/bot/resources/tags/dict-get.md
+++ b/bot/resources/tags/dict-get.md
@@ -1,6 +1,8 @@
Often while using dictionaries in Python, you may run into `KeyErrors`. This error is raised when you try to access a key that isn't present in your dictionary.\
-While you can use a `try` and `except` block to catch the `KeyError`, Python also gives you some other neat ways to handle them.
+While you can use a `try` and `except` block to catch the `KeyError`, Python also gives you some other neat ways to handle them.\
+
__**The `dict.get` method**__
+
The [`dict.get`](https://docs.python.org/3/library/stdtypes.html#dict.get) method will return the value for the key if it exists, or None (or a default value that you specify) if the key doesn't exist. Hence it will _never raise_ a KeyError.
```py
>>> my_dict = {"foo": 1, "bar": 2}