Skip to main content

Mutable sequences

Python Lists: Methods, Slicing, Copies, and Comprehensions

Lists are mutable ordered sequences. Use them when order matters and the collection must grow, shrink, or replace items.

Pythonbeginner4 min readPython fundamentals

Learning overview

Estimated time
4 minutes
Difficulty
Beginner
Prerequisites
No prior experience required
Learning outcome
Explain python using a clear mental model · Apply python in practical Python work
Last updated
July 18, 2026

Use lists as mutable sequences

Indexes begin at zero, negative indexes count from the end, and slices create new lists. Append adds one item, extend adds items from an iterable, and pop removes and returns an item.

list-basics.py
skills = ["HTML", "CSS"]
skills.append("Python")
skills.extend(["SQL", "Git"])
first_two = skills[:2]
last = skills[-1]

Transform clearly with comprehensions

A list comprehension is effective for one readable transformation and optional filter. Use a regular loop when logic needs multiple steps, logging, or exception handling.

comprehension.py
scores = [72, 38, 91, 64]
passing = [score for score in scores if score >= 40]
labels = [f"{score} points" for score in passing]

Copy and sort deliberately

list.copy and slicing produce shallow copies, so nested objects remain shared. sorted returns a new list; list.sort mutates in place and returns None.

Frequently asked questions

What is the difference between append and extend?

Append adds its argument as one item. Extend iterates over its argument and adds each item to the list.

Does list.copy create a deep copy?

No. It copies the outer list only. Nested mutable values remain shared; use copy.deepcopy only when deep-copy semantics are truly required.

Topic graph

A taxonomy-generated path through this subject.

  1. Python
  2. Python fundamentals
  3. python
  4. lists
  5. collections
  6. comprehensions
  7. What Is Python in Programming?
  8. Learn Python: From Fundamentals to Real Applications
  9. Python Tutorial: Build a Command-Line Expense Tracker

Recommended automatically from shared technologies, topics, intent, and difficulty.

Hand-picked companion pages that deepen this topic.

Your next steps

Continue learning

  1. 1glossaryWhat Is Python in Programming?
  2. 2guidesLearn Python: From Fundamentals to Real Applications
  3. 3guidesPython Tutorial: Build a Command-Line Expense Tracker
  4. 4cheatsheetsPython Cheatsheet: Syntax, Collections, Files, and OOP