Python dict() Function
The dict() function creates a dictionary. A dictionary is a
collection which is unordered, changeable and indexed.
Syntax
dict(keyword arguments)
Or
dict(iterable)
Or
dict(mapping)
Parameters
| Parameter | Description |
|---|---|
keyword arguments |
Optional. Keyword arguments: key=value, key=value... |
iterable |
Optional. An iterable with key:value pairs. |
mapping |
Optional. A mapping object (like another dictionary). |
Return Value
A dictionary object.
Example
Using the dict() function:
Output
Click Run to execute your code
Enjoying these tutorials?