💡 What You'll Learn
Lists have built-in methods to add, remove, and organize items. Methods are functions that belong to an object — you call them with a dot: list.method()
.append(item) add to end.insert(i, item) add at position.remove(item) remove first match.pop() remove & return last.sort() arrange in order.reverse() reverse order
list_methods.py
1nums = [3, 1, 4]
2nums.append(2)
3nums.sort()
4print(nums) # [1, 2, 3, 4]
📺 Try the methods!
Your list here
🎯 Your Challenges
1Insert at Position
Use insert(0, item) to add at the beginning
2Find Index
Use index() to find where an item is
3Count Items
Use count() to see how many times an item appears
📚 What You Learned
.append()adds to the end of a list.remove()deletes the first match.sort()orders items (smallest to largest)- Methods use dot notation:
list.method()