Lesson 13 of 55
PythonData Structures – Lists
20 minutes
Course progress24%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 13 of 55
Python20 minutes
Keep these ideas in mind as you work through the lesson.
Lists are ordered, mutable sequences. They’re highly versatile and support many built‑in methods.
colors = ['red', 'green', 'blue']
colors.append('yellow') # add to the end
print(colors[1]) # green
print(colors[-1]) # yellow (last item)
colors.remove('red') # delete first occurrence of 'red'
print(colors) # ['green', 'blue', 'yellow']
Because lists are mutable, you can change, add, or remove elements at any time.