Python6 min read
Python List Methods
Master all important list methods in Python.
Michael Brown
December 18, 2025
0.0k0
All important list operations.
Adding Items
```python fruits = ["apple", "banana"]
Add one item fruits.append("orange") print(fruits) # ['apple', 'banana', 'orange']
Add at position fruits.insert(1, "grape") print(fruits) # ['apple', 'grape', 'banana', 'orange']
Add multiple fruits.extend(["mango", "kiwi"]) print(fruits) ```
Removing Items
```python fruits = ["apple", "banana", "orange", "banana"]
Remove by value (first occurrence) fruits.remove("banana") print(fruits) # ['apple', 'orange', 'banana']
Remove by index item = fruits.pop(1) print(item) # orange print(fruits) # ['apple', 'banana']
Remove all fruits.clear() print(fruits) # [] ```
Sorting and Reversing
```python numbers = [5, 2, 8, 1, 9]
Sort ascending numbers.sort() print(numbers) # [1, 2, 5, 8, 9]
Sort descending numbers.sort(reverse=True) print(numbers) # [9, 8, 5, 2, 1]
Reverse order numbers.reverse() print(numbers) # [1, 2, 5, 8, 9] ```
Searching
```python cities = ["Miami", "Austin", "Denver", "Boston"]
Find index index = cities.index("Denver") print(index) # 2
Count occurrences numbers = [1, 2, 3, 2, 2] print(numbers.count(2)) # 3
Check existence print("Miami" in cities) # True ```
Copy List
```python original = [1, 2, 3]
Shallow copy copy1 = original.copy() copy2 = original[:] copy3 = list(original) ```
Remember
- append() adds one item - extend() adds multiple - pop() returns removed item
#Python#Intermediate#Lists