Flat 10% & up to 50% off + Free additional Courses. Hurry up!

Python Dictionary


Dictionaries are unordered collections of keys and value pair. Dictionaries are mutable. Key should be unique for each value. Key must be unique and immutable. Key and value is separated by a : (colon) . This pair is known as item and items are by comma. In terms of their main properties, dictionaries are:

  • Accessed by key, not offset
  • Unordered collections of arbitrary objects
  • Of the category mutable mapping
  • Tables of object references (hash tables)
  • Variable length, heterogeneous, arbitrarily nestable


print D1




Accessing Values

Dictionaries value is accessed by their keys.



print D1[10]




  • Updation

In dictionary you can modify the existing value and also you can add new item.



D1[20] = "ijk"

D1[30] = "cde"

print D1





Deletion is performed by using key and del is used to delete the item. In this you can delete individual item and also complete dictionary.

 e.g. Deletion individual item


del D1[20]

print D1




e.g. Deletion complete dictionary


del D1

print D1


Traceback (most recent call last):

File “C:/Python27/dict.py”, line 3, in

print D1NameError: name ‘D1′ is not defined


Learn more about PYTHON TOOLKIT in this insightful blog now!


Functions and Methods 

Functions Description
len(dictionary) Returns number of items in a dictionary
cmp(dictionary1,dictionary2) Compares the two dictionaries
str(dictionary) Returns the string representation of a string
dictionary.values() Return the all values of dictionary
dictionary.keys() Return the all keys of dictionary
dictionary.clear() Remove all items of a dictionary and returns an empty dictionary
dictionary.items() Returns the all  items of dictionary
dictionary.copy()  Returns an ordered copy of the data

"0 Responses on Python Dictionary"

Training in Cities

Bangalore, Hyderabad, Chennai, Delhi, Kolkata, UK, London, Chicago, San Francisco, Dallas, Washington, New York, Orlando, Boston

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.


Sales Offer

  • To avail this offer, enroll before 22nd October 2016.
  • This offer cannot be combined with any other offer.
  • This offer is valid on selected courses only.
  • Please use coupon codes mentioned below to avail the offer


Sign Up or Login to view the Free Python Dictionary.