Checkpoint 9.3.1.
- False
- Yes, unlike strings, lists can consist of any type of Python data.
- True
- Lists are heterogeneous, meaning they can have different types of data.
A list can contain only integer items.
[
and ]
).[10, 20, 30, 40]
["spam", "bungee", "swallow"]
[22.5, 23.1, 24.0, 22.9, 26.1, 25.7, 27.8]
["hello", 2.0, 5, False]
len
function can take a list as its argument, and it will return the number of elements in the array.a_list = [3, 67, "cat", 3.14, False]
print(len(a_list))
len
returns the actual number of items in the list, not the maximum index value.