From fe5f72d868313987cb3d6a55de707876046d912d Mon Sep 17 00:00:00 2001 From: Kyle Partridge Date: Fri, 28 Jun 2013 13:55:16 -0700 Subject: added some clarification on the default value for dictionary.get --- python.html.markdown | 4 ++++ 1 file changed, 4 insertions(+) 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 -- cgit v1.2.3