Working with Lists in Python
This article was AI-drafted and has not been reviewed yet. Spotted a mistake? Tell us.
Learn how to create, index, slice, and manipulate lists in Python with this step-by-step tutorial.
Introduction to Lists
Lists are a fundamental data structure in Python, used to store multiple values in a single variable.
Creating Lists
You can create a list by placing values inside square brackets [] and separating them with commas.
fruits = ['apple', 'banana', 'cherry']
print(fruits)
Indexing Lists
You can access a specific element in a list by its index, which starts from 0.
fruits = ['apple', 'banana', 'cherry']
print(fruits[0])
Slicing Lists
You can extract a subset of elements from a list using slicing.
fruits = ['apple', 'banana', 'cherry', 'date', 'elderberry']
print(fruits[1:3])
Manipulating Lists
You can add, remove, and modify elements in a list using various methods.
fruits = ['apple', 'banana', 'cherry']
fruits.append('date')
print(fruits)
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based python courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for python books — check the publication year so the examples match current versions.
Search Amazon →