1. Concept library
  2. Python Foundations
  3. Module 4: Lists and tuples

Concept

List methods

Lists change in place: append, insert, pop, remove, sort and reverse. Most return None, so the list itself is where the result lives.

What a session covers

The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.

  1. Explain which list methods change the list in place and what they return
  2. Use append, insert, pop and remove to edit a list and predict its contents
  3. Spot why names = names.sort() leaves names as None, and fix it with sorted

In practice

A few lines that show List methods doing its job.

Python
queue = ["b", "c"]
queue.append("d")
queue.insert(0, "a")
first = queue.pop(0)
queue.sort(reverse=True)

print(first, queue)          # a ['d', 'c', 'b']
print(sorted(queue))         # new list, original untouched

The common mistake

Watch for

Writing names = names.sort(). sort() changes the list in place and returns None, so names is now None. Use sorted(names) when you want a new list back.

What to know first

Your roadmap puts these before List methods, unless you already know them.

How it stays learned

Once a session shows you understand List methods, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.

  1. Day 3First recall, while it is fresh
  2. Day 7Second, a week on
  3. Day 18Last, when it has settled

Where it leads

Topics that build on List methods.

Previous in the module← Indexing and slicing
Next in the moduleTuples and unpacking →