Python List Methods Built - in Methods for Manipulating Python Lists Prepared by Rachit Joshi 1. Introduction Python lists are ordered and mutable collections used to store multiple values in a single variable. Python provides built - in list methods for adding, removing, searching, counting, sorting, reversing, and copying elements. 2. Python List Methods at a Glance Method Description append() Adds an element to the end of a list. extend() Adds elements from an iterable to the list. insert() Inserts an element at a specified index. remove() Removes the first matching occurrence. pop() Removes and returns an element by index. clear() Removes all elements. index() Returns the first matching index. count() Counts occurrences of an element. sort() Sorts the list in place. reverse() Reverses the list in place. copy() Returns a shallow copy of the list. 3. append() Method Adds one item to the end. Syntax: list_name.append(item) fruits=['apple','mango','banana'] fruits.append('grapes') print(fruits) Output: ['apple', 'mango', 'banana', 'grapes'] 4. extend() Method Adds all elements from an iterable. Syntax: list_name.extend(iterable) items=['milk','bread'] items.extend(['eggs','coffee']) print(items) Output: ['milk', 'bread', 'eggs', 'coffee'] 5. insert() Method Inserts an item at a specified position. Syntax: list_name.insert(index, item) items=['milk','bread','butter'] items.insert(1,'eggs') print(items) Output: ['milk', 'eggs', 'bread', 'butter'] 6. remove() Method Removes the first occurrence of a value. Syntax: list_name.remove(item) items=['milk','bread','butter'] items.remove('butter') print(items) Output: ['milk', 'bread'] 7. pop() Method Removes and returns an item. Without an index, it removes the last item. Syntax: list_name.pop(index) items=['milk','bread','eggs'] removed=items.pop(1) print(items) print(removed) Output: ['milk', 'eggs'] bread 8. clear() Method Removes every element from the list. Syntax: list_name.clear() items=['milk','bread','eggs'] items.clear() print(items) Output: [] 9. index() Method Returns the first index of a matching element. Syntax: list_name.index(item, start, end) items=['milk','bread','eggs','butter'] print(items.index('butter')) Output: 3 10. count() Method Returns the number of occurrences. Syntax: list_name.count(item) items=['egg','milk','egg','bread','egg'] print(items.count('egg')) Output: 3 11. sort() Method Sorts the existing list in place. Syntax: list_name.sort(reverse=False) numbers=[5,2,9,1] numbers.sort() print(numbers) Output: [1, 2, 5, 9] 12. reverse() Method Reverses the order of the existing list. Syntax: list_name.reverse() numbers=[1,2,3,4] numbers.reverse() print(numbers) Output: [4, 3, 2, 1] 13. copy() Method Creates a shallow copy of a list. Syntax: list_name.copy() original=['Python','Java','C++'] new_list=original.copy() print(new_list) Output: ['Python', 'Java', 'C++'] 14. Important Points to Remember • Lists are mutable, so most list methods modify the existing list. • append() adds one item, while extend() adds items from an iterable. • remove() works by value; pop() works by index and returns the removed item. • index() finds a position, while count() counts occurrences. • sort() and reverse() modify the list in place. • copy() creates a shallow copy. 15. Example Combining List Methods numbers=[4,2,7,2] numbers.append(9) numbers.extend([1,5]) numbers.remove(2) numbers.sort() print(numbers) print("Count of 2:", numbers.count(2)) 16. Conclusion Python list methods make common collection operations simple and readable. Learning append(), extend(), insert(), remove(), pop(), clear(), index(), count(), sort(), reverse(), and copy() provides a strong foundation for working with lists in Python programs.