Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

dictionary in python

#A dictionary has key-value pairs. Here 1,2,3 are the keys and Item1,Item2,Item3 
#are their values respectively. 
dictionaryName = { 1: "Item1", 2: "Item2", 3: "Item3"}

#retrieving value of a particular key
dictionaryName[1]

#retrieving all the keys in a dictionary
dictionaryName.keys()

#retrieving all the values in a dictionary
dictionaryName.values()
Source by gto76.github.io #
 
PREVIOUS NEXT
Tagged: #dictionary #python
ADD COMMENT
Topic
Name
4+8 =