List Methods
List methods are tools that change or inspect a list.
You call them with a dot after the list name.
Many of them change the list in place.
That means the shelf itself gets updated.
append and insert
append adds one item at the end.
insert puts an item at a chosen place.
extend and +
extend adds many items from another list.
+ can join two lists into a new list.
extend changes the first list. + builds a new one.
remove, pop, and clear
remove deletes the first matching value.
pop pulls out an item by index and returns it.
clear empties the whole list.
Finding items
index finds the place of a value.
count counts how many times a value appears.
Use in to ask if a value is there.
sort and reverse
sort puts items in order.
reverse flips the current order.
Both change the list itself.
sort() for small to big
sort(reverse=True) for big to small
reverse() flips whatever order you have now
sorted(list) makes a new sorted list and leaves the old one
copy a list
If you write b = a, both names point to the same shelf.
Use copy if you want a second shelf.
Tip: Remember which methods change the list and which return a new value.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.