The list()
function is a constructor function for list data type. It is used to create a list from an iterable object, such as a string, tuple, range, etc. It is also called without any argument as an alternative to empty brackets to create an empty list.
list(iterable= None)
iterable |
An iterable object such as a tuple, string, dictionary, etc to be casted into a list. |
If the function is called without any argument, it simply returns an empty list. When the iterable argument is given, it returns a list containing the elements of the iterable.
In the following section we create non-empty lists using the list()
function.