summaryrefslogtreecommitdiffhomepage
path: root/python.html.markdown
diff options
context:
space:
mode:
authorKyle Partridge <partkyle@gmail.com>2013-06-28 13:55:16 -0700
committerKyle Partridge <partkyle@gmail.com>2013-06-28 13:55:16 -0700
commitfe5f72d868313987cb3d6a55de707876046d912d (patch)
tree53704ba24614d8fea0dcee188836cf4c28523392 /python.html.markdown
parent2e805c8c020719da0aab40987b7c064c864db9c8 (diff)
added some clarification on the default value for dictionary.get
Diffstat (limited to 'python.html.markdown')
-rw-r--r--python.html.markdown4
1 files changed, 4 insertions, 0 deletions
diff --git a/python.html.markdown b/python.html.markdown
index 39a2349d..a3ced659 100644
--- a/python.html.markdown
+++ b/python.html.markdown
@@ -200,6 +200,10 @@ filled_dict.values() #=> [3, 2, 1]
filled_dict["four"] #=> KeyError
# Use get method to avoid the KeyError
+filled_dict.get("one") #=> 1
+filled_dict.get("four") #=> None
+
+# The get method supports a default argument when the value is missing
filled_dict.get("one", 4) #=> 1
filled_dict.get("four", 4) #=> 4