Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Removing Elements from Python Dictionary Using del keyword

# welcome to softhunt.net
# Creating a Dictionary
Dictionary = {0: 'Softhunt', 1: '.net',
		2:{'i' : 'By', 'ii' : 'Ranjeet', 'iii' : 'Andani'}, 3: 'Greetings'}
print('Initial Dictionary: ', Dictionary)

# Deleting a Key value
del Dictionary[1]
print("
Deleting a specific key: ", Dictionary)

# Deleting a Key from
# Nested Dictionary
del Dictionary[2]['i']
print("
Deleting a key from Nested Dictionary: ", Dictionary)
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Removing #Elements #Python #Dictionary #Using #del #keyword
ADD COMMENT
Topic
Name
6+6 =