Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Dictionary get both key and value.

# get value of given key

hh = {"a":1, "b":2}

print(hh.get("b")) # 2

print(hh.get("x")) # None

print(hh.get("x", 8)) # 8
Source by xahlee.info #
 
PREVIOUS NEXT
Tagged: #Dictionary #key
ADD COMMENT
Topic
Name
8+9 =