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

Home
Python Tutorial
1.Introduction
2.Data Type
3.Statement
4.Operator
5.String
6.Tuple
7.List
8.Dictionary
9.Collections
10.Function
11.Class
12.File
13.Buildin Function
14.Buildin Module
15.Database
16.Regular Expressions
17.Thread
18.Tkinker
19.wxPython
20.XML
21.Network
22.CGI Web
23.Windows
Python Tutorial » Dictionary » Delete 
8.7.2.Creating, accessing and modifying a dictionary.
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.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.