dict()
dict() is a Python function in the Built-in Functions category. Creates a dictionary from keyword arguments, a mapping, or an iterable of key-value pairs. The syntax is dict(**kwargs) / dict(mapping) / dict(iterable). Parameters: mapping/iterable/kwargs — data to populate the dict. Returns: Dictionary. A typical example: dict(a=1, b=2) # {"a": 1, "b": 2}
dict([("a", 1), ("b", 2)]) # {"a": 1, "b": 2}. A close sibling is print(), which prints objects to the text stream, separated by `sep` and followed by `end`. A close sibling is len(), which returns the length (number of items) of an object. Works with sequences, collections, and strings. A close sibling is range(), which returns an immutable sequence of numbers. Commonly used in for loops. A close sibling is type(), which returns the type of an object, or creates a new type with three arguments. More about this category: Python's built-in functions available without importing — print, len, range, map, and more.