September 24

Dictionary

Dictionary is a key value pair,mapping between a set of keys and a set of values.
Association of a key and a value is called key-value pair or an item.
Python dictionary is like hash in Perl, an instance of Hashtable class in Java or an instance of the Scripting.Dictionary object in Visual Basic.

Key features of dictionaries

  • dictionary can not have duplicate keys
  • assigning new value to existing key will simply replace the old value
  • dictionary value can be any datatype, within a single dictionary you can have multiple datatype as value
  • dictionary key can be any immutable datatype
  • Deleting Items From Dictionaries
    Dictionary has two method to delete/clear the data

    • del, will delete individual item from dictionary
    • clear , will clear all the data and give you a empty dictionary


Copyright 2021. All rights reserved.

Posted September 24, 2015 by admin in category "Data Types", "Dictionary