The list() function in Python is a built-in function used to create a new list object. It can be called with no arguments to create an empty list, or it can be passed an iterable object as an argument to create a list containing the elements of that iterable. For example, list([1, 2, 3]) will return [1, 2, 3].
Parameter Values
| Parameter | Description |
|---|---|
| iterable | An |
Return Values
The list() function in Python can return a new list object.
How to Use list() in Python
Example 1:
The list() function returns a list from the given iterable or generates an empty list if no arguments are provided.
list(range(5))
Example 2:
The list() method can also convert a string into a list of individual characters.
list('hello')
Example 3:
You can pass a tuple as an argument to list() to convert it into a list.
list((10, 20, 30))