Concepts·Certified Entry-Level Python Programmer
Python List Methods and Copying
The second half of objective 3.1. The methods are easy to list and easy to get wrong in one specific way: the mutating ones return `None`, so `xs = xs.sort()` destroys the list. Copying is the deeper subject - `b = a` gives two names for one list, `a[:]` gives a real copy, and neither copies the lists *inside* a list. That last point is where PCAP's most-asked OOP question comes from.
Data Collections Guide 14 of 26 Beginner
- Python3.14.4
- OSUbuntu 26.04 LTS
- pip25.1.1
- TimeAbout 18 min
- Reviewed23 August 2026
Written against the versions above. Nothing here is version-dependent. `list.copy()` was added in Python 3.3 and is equivalent to `xs[:]`; both are shown, because a question may use either.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| RUNNER01 | 192.168.0.27 | Ubuntu 26.04 LTS | Python 3.14.4 - the only machine this path needs | 2 Core | 4 GB | 50 GB |
Before you start
- guide 13 - the first half of objective 3.1.
- Nothing else.
-
The methods that add
-
The methods that remove
-
How removal fails
-
sort() returns None, sorted() returns a list
-
What cannot be sorted
-
Searching and counting
-
index() on something absent
-
b = a does not copy anything
-
A copy of a list of lists is not a copy of the inner lists
-
The repetition trap
-
What the exam does with this half of the objective