Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Creating a Dictionary using built-in function dict()

# welcome to softhunt.net
# Creating an empty Dictionary
Dictionary = {}
print("Empty Dictionary: ")
print(Dictionary)

# Creating a Dictionary
# with Dictionary() method
Dictionary = dict({0: 'Softhunt', 1: '.net', 2: 'By', 3: 'Ranjeet'})
print("
Dictionary with the use of dict(): ")
print(Dictionary)

# Creating a Dictionaryionary
# with each item as a Pair
Dictionary = dict([(0, 'Ranjeet'), (1, 'Kumar'), (2, 'Andani')])
print("
Dictionary with each item as a pair: ")
print(Dictionary)
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Creating #Dictionary #function
ADD COMMENT
Topic
Name
7+8 =