Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python get value from dictionary

dict = {'color': 'blue', 'shape': 'square', 'perimeter':20}
dict.get('shape') #returns square

#You can also set a return value in case key doesn't exist (default is None)
dict.get('volume', 'The key was not found') #returns 'The key was not found'
Source by note.nkmk.me #
 
PREVIOUS NEXT
Tagged: #python #dictionary
ADD COMMENT
Topic
Name
4+2 =