diff options
Diffstat (limited to '')
| -rw-r--r-- | bot/resources/tags/dict-get.md | 4 | 
1 files changed, 2 insertions, 2 deletions
| diff --git a/bot/resources/tags/dict-get.md b/bot/resources/tags/dict-get.md index 6f8299dc7..7657f420a 100644 --- a/bot/resources/tags/dict-get.md +++ b/bot/resources/tags/dict-get.md @@ -1,5 +1,5 @@  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**__ @@ -8,7 +8,7 @@ The [`dict.get`](https://docs.python.org/3/library/stdtypes.html#dict.get) metho  >>> my_dict = {"foo": 1, "bar": 2}  >>> print(my_dict.get("foobar"))  None ->>> print(my_dict.get("foobar", 3))    # here 3 is the default value to be returned, in case the key doesn't exist +>>> print(my_dict.get("foobar", 3))    # here 3 is the default value to be returned, because the key doesn't exist  3  ``` | 
