Lists — Create, Access & Modify
Lists are ordered, mutable collections. They can hold any data type and are the most versatile data structure in Python.
20 min•By Priygop Team•Updated 2026
Lists Basics
Lists Basics
# Creating lists
fruits = ["apple", "banana", "cherry"]
numbers = [1, 2, 3, 4, 5]
mixed = [1, "hello", True, 3.14]
empty = []
# Accessing elements (0-indexed)
print(fruits[0]) # apple
print(fruits[-1]) # cherry (last item)
# Modifying elements
fruits[1] = "blueberry"
print(fruits) # ['apple', 'blueberry', 'cherry']
# Adding elements
fruits.append("date") # add to end
fruits.insert(1, "avocado") # insert at index
print(fruits)
# List length
print(len(fruits)) # 5
# Check membership
print("apple" in fruits) # True
print("mango" in fruits) # FalseTip
Tip
Use 'in' to check membership: if 'apple' in fruits. It's cleaner and more Pythonic than looping to find an item.
Diagram
Loading diagram…
List for mutable sequences, tuple for immutable data, set for unique items
Common Mistake
Warning
Lists are 0-indexed. fruits[1] is the second item, not the first. fruits[-1] gets the last item safely.
Practice Task
Note
(1) Create a list of 5 fruits. (2) Access the first and last items. (3) Modify the third item. (4) Append two new items.