What is Dictionary in Python

Dictionary is the data type of python used to store data in key value pairs. Dictionary is unordered, changeable and indexed. It is written with curly brackets

Example-

>>> my_dict = {'name':'Rahul Garg', 'age':40, 'gender':'Male'}
>>> print(my_dict)
{'name': 'Rahul Garg', 'age': 40, 'gender': 'Male'}
>>> 

 

Total Views: 426

Related FAQs

Q. How to clear dictionary in Python?

Ans: Python dictionary method clear() removes all items from the dictionary. Syntax: dict.clear() Example:-- d = {'uid': 3233, 'email_id': '[email protected]'}; print("Before Clear - ", ... read more