Scroll Down to See All▾
absaiterallanextanyasciibinboolbreakpointbytearraybytescallablechrclassmethodcompilecomplexdelattrdivmodenumerateevalexecfilterfloatformatfrozensetgetattrglobalshasattrhashhelphexidinputintisinstanceissubclassiterlenlistlocalsmapmaxmemoryviewminnextobjectoctopenordpowprintpropertyrangereprreversedroundsetsetattrslicesortedstaticmethodstrsumsupertupletypevarszip__import__clear_(dict)clear_(list)clear_(set)copy_(dict)copy_(list)copy_(set)fromkeysgetitemskeyspop_(dict)pop_(list)pop_(set)popitemsetdefaultupdatevaluescount_(tuple)count_(list)count_(str)index_(tuple)index_(list)index_(str)adddifferencedifference_updatediscardintersectionintersection_updateisdisjointissubsetissupersetremove_(set)remove_(list)symmetric_differencesymmetric_difference_updateunionupdateclosefilenoflushisattyreadreadablereadlinereadlinesseekseekabletelltruncatewritablewritewritelinesappendextendinsertreversesortcapitalizecasefoldcenterencodeendswithexpandtabsfindformatisalnumisalphaisasciiisdecimalisdigitisidentifierislowerisnumericisprintableisspaceistitleisupperjoinljustlowerlstripmaketranspartitionreplacerfindrindexrjustrpartitionrsplitrstripsplitsplitlinesstartswithstripswapcasetitletranslateupperdirzfillFunction Details: dict
Description
Creates a new dictionary.
Extended Description
The dict() function creates a new dictionary. It can be called with various types of arguments: no argument (to create an empty dictionary), a mapping object, an iterable of key/value pairs, or keyword arguments. Dictionaries store key-value pairs and are mutable, ordered (as of Python 3.7), and do not allow duplicate keys.
Exceptions
- TypeError: If the iterable contains elements that are not key-value pairs
- ValueError: If a key is specified multiple times in the iterable
Read More about dict from Python Documentation
Function Signature
dict(iterable: Optional[Iterable] = None, **kwargs: Any) -> dict
Module: builtins
Class: dict
Parameters
iterable: An optional iterable of key-value pairs to initialize the dictionary. **kwargs: Keyword arguments to be added as key-value pairs to the dictionary.
Parameter List
- iterable: Optional[Iterable]
- **kwargs: Any
Return
Returns a new dictionary object.
Return Type
dict
Output
Explanation
This example demonstrates various ways to create dictionaries using the dict() function.