Scroll Down to See All▾
absaiterallanextanyasciibinboolbreakpointbytearraybytescallablechrclassmethodcompilecomplexdelattrdictdivmodenumerateevalexecfilterfloatformatfrozensetgetattrglobalshasattrhashhelphexidinputintisinstanceissubclassiterlenlistlocalsmapmaxmemoryviewminnextobjectoctopenordpowprintpropertyrangereprreversedroundsetsetattrslicesortedstaticmethodstrsumsupertupletypevarszip__import__clear_(dict)clear_(list)clear_(set)copy_(dict)copy_(list)copy_(set)getitemskeyspop_(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: fromkeys
Description
Creates a new dictionary with keys from iterable and values set to value.
Extended Description
The fromkeys() method is a class method that creates a new dictionary. The first parameter is an iterable defining the keys of the new dictionary. The second optional parameter specifies the value for all keys, which defaults to None if not provided. This method is particularly useful when you want to create a dictionary with preset keys and a default value.
Function Signature
dict.fromkeys(iterable: Iterable, value: Any = None) -> dict
Module: dict
Class: dictionary
Parameters
Parameter List
- iterable: Iterable
- value: Any
Return
Returns a new dictionary with keys from the iterable and values set to the specified value.
Return Type
dictionary
Output
Explanation
This example creates a dictionary with keys from a list and sets all values to 0.