Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Accessing elements from a Python Dictionary

# welcome to softhunt.net
# Python program to demonstrate
# accessing a element from a Dictionary

# Creating a Dictionary
Dictionary = {0: 'Softhunt', 1: '.net', 2: 'By Ranjeet', 'user': 'Greetings to you'}
print("Dictionary", Dictionary)

# accessing a element using key
print("Accessing a element using key:", Dictionary['user'])

# accessing a element using key
print("Accessing a element using key:", Dictionary[2])
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Accessing #elements #Python #Dictionary
ADD COMMENT
Topic
Name
4+2 =