summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam Bard <github@adambard.com>2013-06-28 14:02:13 -0700
committerAdam Bard <github@adambard.com>2013-06-28 14:02:13 -0700
commit16199fe04c54977a70d1ae6160e7715483e04e30 (patch)
tree53704ba24614d8fea0dcee188836cf4c28523392
parent2e805c8c020719da0aab40987b7c064c864db9c8 (diff)
parentfe5f72d868313987cb3d6a55de707876046d912d (diff)
Merge pull request #19 from partkyle/dictionary-clarification
Added some clarification on the default value for dictionary.get
-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