The list function
The list function creates a new list from the original object. In the parameter, we specify the object from which we will make the list.
Syntax
list(the object from which we make a list)
Example
Let's use the list function to make a list from a string:
txt = 'abcdef'
lst = list(txt)
print(lst)
Result of code execution:
['a', 'b', 'c', 'd', 'e', 'f']
Example
Now let's make a list from a tuple:
tlp = ('ab', 1, 'cd', 2)
lst = list(tlp)
print(lst)
Result of code execution:
['ab', 1, 'cd', 2]
Example
Let's make a list of the many:
st = {1, 2, 3, 4}
lst = list(st)
print(lst)
Result of code execution:
[1, 2, 3, 4]