Search⌘ K
AI Features

Lists

Explore how to work with Python lists by learning their structure, indexing methods including negative indexes, and how to change elements or find list length. This lesson builds foundational skills for handling sequences in Python programming.

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.

Python 3.5
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 ...