Pythin dict() function
Published February 15, 2022A dict() function is a Python built-in function for creating a Python dictionary. A dictionary is just a collection of key-value pairs. A dictionary has a changeable structure, which implies that its data may be updated. A dictionary is an expanded data structure, and its content may be quickly retrieved via indexes.
How to Create a Dictionary in Python
To create a dictionary in Python, you only need to pass the keyword arguments as the parameter with all the needed values that will be the dictionary's values and keys.
The syntax is as follows:
Class dict(dictionary content) |
Example
myDictionary = dict(p=1, q=2, r=3, s=4) print(myDictionary) |
Output
Article Contributed By :
|
|
|
|
229 Views |