Understanding lists in Python 3 is one of the most important and frequently used skills in Python programming — lists are mutable, ordered sequences that let you store and manipulate collections of related values (numbers, strings, objects, even other lists), making them perfect for data storage, iteration, sorting, filtering, and almost every real-world task (from to-do apps to data analysis, game inventories, user inputs, and machine learning datasets).
In this up-to-date 2025–2026 guide, you’ll master exactly how lists in Python 3 work: creating lists, indexing & slicing, modifying items, concatenating & replicating, removing items, nested lists, operators (+, *, +=, *=), and best practices. All examples are tested on Python 3.10–3.13.
Key Takeaways
- Lists in Python 3 are mutable, ordered, zero-indexed sequences defined with [].
- Access items with indexing: positive (0-based) or negative (-1 = last).
- Slice with [start:end:step] — start inclusive, end exclusive, step optional.
- Modify items directly: my_list[0] = “new_value” — lists are mutable!
- Concatenate with +, replicate with *, compound +=/*=.
- Nested lists: lists inside lists — access with multiple indices.
- Remove items with del, .pop(), .remove(), .clear().
- Lists can hold mixed types — very flexible for real-world data.
Prerequisites
- Python 3.8+ installed
- Basic Python knowledge (print, variables, strings)
- Interactive shell (python3) or script file
1. Creating & Printing Lists
# String list
sea_creatures = ['shark', 'cuttlefish', 'squid', 'mantis shrimp', 'anemone']
print(sea_creatures)
# ['shark', 'cuttlefish', 'squid', 'mantis shrimp', 'anemone']
# Mixed types
mixed = [42, "hello", 3.14, True, None]
print(mixed)
# [42, 'hello', 3.14, True, None]
# Empty list
empty = []
print(len(empty)) # 0
2. Indexing Lists in Python 3
Zero-based positive indexing:
print(sea_creatures[0]) # shark
print(sea_creatures[2]) # squid
Negative indexing (from end):
print(sea_creatures[-1]) # anemone
print(sea_creatures[-3]) # squid
IndexError if out of range:
# print(sea_creatures[10]) # IndexError
3. Slicing Lists
Extract sublists with [start:end:step]:
print(sea_creatures[1:4]) # ['cuttlefish', 'squid', 'mantis shrimp']
print(sea_creatures[:3]) # ['shark', 'cuttlefish', 'squid']
print(sea_creatures[2:]) # ['squid', 'mantis shrimp', 'anemone']
print(sea_creatures[::2]) # ['shark', 'squid', 'anemone'] (every 2nd)
print(sea_creatures[::-1]) # ['anemone', 'mantis shrimp', 'squid', 'cuttlefish', 'shark'] (reverse)
4. Modifying Lists (Mutability)
Change items directly:
sea_creatures[1] = 'octopus'
print(sea_creatures)
# ['shark', 'octopus', 'squid', 'mantis shrimp', 'anemone']
sea_creatures[-2] = 'blobfish'
print(sea_creatures)
# ['shark', 'octopus', 'squid', 'blobfish', 'anemone']
5. Concatenating & Replicating Lists
# Concatenate with +
more_creatures = ['yeti crab', 'seahorse']
all_creatures = sea_creatures + more_creatures
print(all_creatures)
# Replicate with *
print(sea_creatures * 2)
# Compound assignment
sea_creatures += ['fish']
print(sea_creatures)
6. Removing Items from Lists
# Delete by index
del sea_creatures[1] # removes 'octopus'
# Delete range
del sea_creatures[2:4] # removes items 2 and 3
# Remove by value
sea_creatures.remove('shark')
# Pop (remove & return)
last = sea_creatures.pop() # removes & returns last item
print(last) # 'fish'
# Clear entire list
sea_creatures.clear()
7. Nested Lists
Lists inside lists:
sea_names = [
['shark', 'octopus', 'squid'],
['Sammy', 'Jesse', 'Drew']
]
print(sea_names[0][1]) # octopus
print(sea_names[1][0]) # Sammy
8. Best Practices & Modern Tips (2025–2026)
- Use descriptive names: user_scores > l
- Prefer list comprehensions for creation: [x**2 for x in range(10)]
- Avoid modifying lists while iterating — use copies or comprehensions.
- Use enumerate() for index + value: for i, creature in enumerate(sea_creatures): …
- Type hints: scores: list[float] = [95.5, 88.0]
- For immutable sequences → use tuples instead of lists.
FAQ (2025–2026)
- How do I create lists in Python 3?
Use square brackets: my_list = [1, “text”, 3.14] — easiest way to start. - How do I access items in lists in Python 3?
Use indexing: my_list[0] (first), my_list[-1] (last). - How do I slice lists in Python 3?
[start:end:step] — e.g., [1:5:2] — powerful way to extract sublists. - Are lists in Python 3 mutable?
Yes — change items directly: my_list[0] = “new_value”. - How do I remove items from lists in Python 3?
del, .remove(), .pop(), .clear() — multiple ways to modify lists in Python 3.
Summary
You now know exactly how lists in Python 3 work: creating, indexing & slicing, modifying, concatenating & replicating, removing items, nested lists, operators, and modern best practices.
Mastering lists in Python 3 unlocks powerful data handling — storing collections, iterating, filtering, sorting, processing user input, and more. Lists are one of the most versatile and commonly used data structures in Python.
Recommended Next Tutorials
- Python List Methods (.append(), .extend(), .sort(), etc.)
- List Comprehensions in Python 3
- Python Tuples vs Lists – When to Use Each
- Python Nested Lists & Matrices
- Build a To-Do List Manager with Lists