Python Essential List Methods
Lists come packed with built-in tools called methods. You call them with a dot notation like my_list.sort(). Want to add an element? .append(). Want to remove and retrieve the last item? .pop(). Want to sort numbers? .sort().
"Think of a list as a smart filing cabinet. Instead of rearranging the folders manually, you can push a button called .sort() and the cabinet reorganizes everything automatically."
Deep Dive: How It Works
.append(x): Adds item x to the end of the list in O(1) constant time.
.insert(index, x): Inserts item x at a specific index, shifting subsequent elements to the right.
.pop(index): Removes and returns the item at index (defaults to the last item if no index is passed).
.remove(x): Searches for the first occurrence of value x and removes it from the list.
.sort(): Sorts the list in ascending order in place (modifying the original list). For descending order, pass reverse=True: my_list.sort(reverse=True).
.reverse(): Reverses the elements of the list in place.
Syntax Blueprint
nums = [3, 1, 2] nums.append(4) # [3, 1, 2, 4] nums.sort() # [1, 2, 3, 4] last = nums.pop() # returns 4, list is now [1, 2, 3]
Methods like .sort() and .reverse() modify the list directly without creating a new copy.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Assigning the result of .sort(): sorted_list = my_list.sort()Why it happens: .sort() modifies the list in place and returns None, so sorted_list becomes None!
How to fix: Either call my_list.sort() on its own line, or use the built-in sorted(my_list) function.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Sort a list of numbers
Given data = [5, 2, 9, 1], sort it using data.sort().
Print the sorted list.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.