Lists
Learn how to create, access, and modify lists to store and manage data.
Lists is a free Learn AI with Python lesson on CoddyKit — lesson 1 of 5. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Learn AI with Python learning path, one of 5 lessons in the course, and your progress syncs across the web and the CoddyKit app.
1
Introduction to Lists
Lists are one of the most commonly used data structures in Python. They are mutable, ordered collections that can hold multiple items of any type.
In this lesson, you’ll learn how to create and manipulate lists, use list methods, and iterate over lists.

2
Creating Lists
A list is created by placing items inside square brackets [], separated by commas:
# Creating a list
fruits = ["apple", "banana", "cherry"]
print(fruits)3
4
List Indexing and Slicing
You can access list items using their index. Indexing starts at 0. Slicing is used to retrieve a portion of the list:
# Indexing and slicing a list
fruits = ["apple", "banana", "cherry", "date"]
print(fruits[1]) # Outputs: banana
print(fruits[1:3]) # Outputs: ['banana', 'cherry']5
List Operations
Lists support various operations like concatenation and repetition:
# List operations
fruits = ["apple", "banana"]
print(fruits + ["cherry"]) # Outputs: ['apple', 'banana', 'cherry']
print(fruits * 2) # Outputs: ['apple', 'banana', 'apple', 'banana']6
Iterating Over Lists
You can use a for loop to iterate over a list:
# Iterating over a list
fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
print(fruit)7
Common List Methods
Python lists come with many useful methods:
append(): Adds an item to the end of the list.remove(): Removes a specified item.sort(): Sorts the list.
# Using list methods
fruits = ["banana", "apple", "cherry"]
fruits.append("date")
print(fruits) # Outputs: ['banana', 'apple', 'cherry', 'date']8
Nested Lists
A list can contain other lists, forming a nested list:
# Working with nested lists
nested_list = [[1, 2, 3], [4, 5, 6]]
print(nested_list[0]) # Outputs: [1, 2, 3]
print(nested_list[0][1]) # Outputs: 29
10
Common Mistakes with Lists
Here are some mistakes to avoid:
- Using incorrect indices when accessing list items.
- Modifying a list while iterating over it.
- Forgetting that lists are mutable and changes affect all references.
11
What Did We Learn?
In this lesson, you learned:
- How to create and manipulate lists in Python.
- Common list operations and methods.
- How to use nested lists and iterate over lists.
Great job! Let’s move to the next topic.

Frequently asked questions
Is the “Lists” lesson free?
Yes — the full text of “Lists” is free to read here on the web, and the Learn AI with Python course includes 5 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Learn AI with Python course, upgrade to CoddyKit PRO.
What will I learn in “Lists”?
Learn how to create, access, and modify lists to store and manage data. You practise Learn AI with Python with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Learn AI with Python?
No prior experience is required. Learn AI with Python on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 5, so you can start here or from the beginning and move at your own pace.
How long does the “Lists” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Learn AI with Python lesson?
Yes. Every Learn AI with Python lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.