TOPIC 5: Python Lists
Completion requirements
6. The type() Function & The list() Constructor
The type() Function
From Python's perspective, lists are objects with the data type list.
Example:
mylist = ["apple", "banana", "cherry"]
print(type(mylist))
Output:
<class 'list'>
The list() Constructor
Python also provides a list() constructor for creating lists.
Example:
thislist = list(("apple", "banana", "cherry"))
print(thislist)
Output:
['apple', 'banana', 'cherry']
Note: The list constructor uses double parentheses because the values are passed as a tuple before being converted into a list.