Creating, accessing and modifying a dictionary. : Delete « Dictionary « Python Tutorial






emptyDictionary = {}
print emptyDictionary

grades = { "A": 87, "B": 76, "C": 92, "D": 89 }
print "\nAll grades:", grades

print grades[ "A" ]
grades[ "A" ] = 90
print "A's new grade:", grades[ "A" ]

# add to an existing dictionary
grades[ "B" ] = 93
print "\nDictionary grades after modification:"
print grades

# delete entry from dictionary
del grades[ "C" ]
print "\nDictionary grades after deletion:"
print grades








8.7.Delete
8.7.1.Deleting Items from a Dictionary
8.7.2.Creating, accessing and modifying a dictionary.