This page topics close

Dictionary represent the collection of elements in the form of key - value pair.Dictionary is an unordered set of key and value pair. It is a container that contains data, enclosed within curly braces.

Dictionaries are indexed by keys, which can be any immutable type; strings and numbers can always be keys.

Tuples can be used as keys if they contain only strings, numbers, or tuples; if a tuple contains any mutable object either directly or indirectly, it cannot be used as a key.

Keys of Dictionary must be unique.

  • Example of creating Dictionary

    # creating Dictionary
    {'name': 'John', 'phone': 13345658, 'city': 'lucknow'}

What next?

The next topic is Python List

Share this page