Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to define a dictionary in python

population = {"Shanghai":17.8, "Istanbul":13.3, "Karachi":13.0, "Mumbai":12.5}

#Consider the following when creating a dictionary
#	1. Must be inside {}
#	2. Have two parts in an item 
#			Key - e.g. Istanbul and Value - e.g. 13.3
#	3. There must be a colon ":" between the key and the value
#	4. Item must be seperated by commas ","
#	3. Any immutable type can be used as keys (not only integers like in lists)
Source by codefreelance.net #
 
PREVIOUS NEXT
Tagged: #define #dictionary #python
ADD COMMENT
Topic
Name
4+9 =