Lists

Let's look at the list data type in more detail.

Definition

A list is a sequence of values enclosed in square brackets. It is extremely versatile as you can store multiple items of different data types inside of it. A list can also be treated as if it were an array.

Press + to interact
my_list_emp = [] # empty list
print(my_list_emp)
my_list_int = [8, 9, 10] # list of integers
print(my_list_int)
my_list_ftr = [1.25, 3.45, 6.12] # list of floats
print(my_list_ftr)
my_list_mixed = ["Buckle", 2, "Shoes"] # list of mixed data types
print(my_list_mixed)

Indexing

Lists are also zero-indexed, meaning the first item in the list is assigned an index of 0.

Therefore, if for example, a list called my_list ...