Python List MethodsLast Updated : 3 Jan 2026 Python Lists offers a wide range of built-in methods to manipulate data efficiently. List in Python, is an ordered and mutable data type allowing us to store multiple values in a single variable. Let us take a look at various List methods available in Python.
1) append()The append() method in Python allows us to add an element at the end of the list. Syntax:It has the following syntax: Python append() Method ExampleLet us take an example to demonstrate the append() method in Python. ExampleCompile and RunOutput: List of Fruits: ['apple', 'mango', 'banana', 'orange', 'guava'] Updated List of Fruits: ['apple', 'mango', 'banana', 'orange', 'guava', 'grapes'] Explanation: In the above example, we have used the append() method to add a new element 'grapes' at the end of the given list. 2) extend()The extend() method in Python allows us to append all the elements from an iterable (list, tuple, set, etc.) at the end of the list. Syntax:It has the following syntax: Python extend() Method ExampleLet us take an example to demonstrate the extend() method in Python. ExampleCompile and RunOutput: Old Shopping List: ['milk', 'bread', 'butter'] New Items: ['eggs', 'apples', 'coffee'] Updated Shopping List: ['milk', 'bread', 'butter', 'eggs', 'apples', 'coffee'] Explanation: In the above example, we have used the extend() method to add an iterable at the end of the given list. 3) insert()The insert() method in Python allows us to insert an the elements at a specified position in the list. Syntax:It has the following syntax: Python insert() Method ExampleLet us take an example to illustrate how the insert() method works in Python. ExampleCompile and RunOutput: Old Shopping List: ['milk', 'bread', 'butter', 'coffee'] New Shopping List: ['milk', 'bread', 'eggs', 'butter', 'coffee'] Explanation: In the above example, we have used the insert() method to insert item 'eggs' at the second index of the given list. 4) remove()The remove() method in Python allows us to remove the first occurrence of the specified element from the list. Syntax:It has the following syntax: Python remove() Method ExampleLet us take an example to demonstrate the remove() method in Python. ExampleCompile and RunOutput: Old Shopping List: ['milk', 'bread', 'eggs', 'butter', 'coffee'] New Shopping List: ['milk', 'bread', 'eggs', 'coffee'] Explanation: In the above example, we have used the remove() method to remove item 'butter' from the given list. 5) pop()The pop() method in Python allows us to remove and return the element from the specified index of the given list. Syntax:It has the following syntax: Python pop() Method ExampleLet us take an example to demonstrate the pop() method in Python. ExampleCompile and RunOutput: Old Shopping List: ['milk', 'bread', 'eggs', 'butter', 'coffee'] New Shopping List: ['milk', 'eggs', 'butter', 'coffee'] Popped Item: bread Explanation: In the above example, we have used the pop() method to remove and return the item at index '2' from the given list. 6) clear()The clear() method in Python allows us to remove all the elements from the list making it empty. Syntax:It has the following syntax: Python clear() Method ExampleLet us take an example to demonstrate the clear() method in Python. ExampleCompile and RunOutput: Old Shopping List: ['milk', 'bread', 'eggs', 'butter', 'coffee'] New Shopping List: [] Explanation: In the above example, we have used the clear() method to remove all the elements from the given list. 7) index()The index() method in Python returns the first index of the element within start and end. Syntax:It has the following syntax: Python index() Method ExampleLet us take an example to demonstrate the index() method in Python. ExampleCompile and RunOutput: Shopping List: ['milk', 'bread', 'eggs', 'butter', 'coffee'] Index of butter: 3 Explanation: In the above example, we have used the index() method to find the first occurrence of the element from the given list. 8) count()The count() method in Python allows us to all the occurrence of the element in the list. Syntax:It has the following syntax: Python count() Method ExampleLet us take an example to demonstrate the count() method in Python. ExampleCompile and RunOutput: Shopping List: ['milk', 'bread', 'egg', 'milk', 'butter', 'coffee', 'egg', 'flour', 'egg'] No. of Eggs: 3 Explanation: In the above example, we have used the count() method to find all the occurrences of 'egg' in the given list. 9) sort()The sort() method in Python allows us to sort the list in place. Syntax:It has the following syntax: Python sort() Method ExampleLet us take an example to illustrate how the sort() method works in Python. ExampleCompile and RunOutput: Unsorted Fruit Basket: ['mango', 'apple', 'orange', 'banana', 'grapes'] Sorted Fruit Basket: ['apple', 'banana', 'grapes', 'mango', 'orange'] Explanation: In the above example, we have used the sort() method to sort the elements of the given list in ascending order. 10) reverse()The reverse() method in Python allows us to reverse the list in place. Syntax:It has the following syntax: Python reverse() Method ExampleLet us take an example to illustrate how the reverse() method works in Python. ExampleCompile and RunOutput: Fruit Basket: ['apple', 'banana', 'grapes', 'mango', 'orange'] Reversed Fruit Basket: ['orange', 'mango', 'grapes', 'banana', 'apple'] Explanation: In the above example, we have used the reverse() method to reverse the given list. 11) copy()The copy() method in Python allows us to create a shallow copy of the list. Syntax:It has the following syntax: Python copy() Method ExampleLet us take an example to illustrate how the copy() method works in Python. ExampleCompile and RunOutput: Fruit Basket: ['apple', 'banana', 'grapes', 'mango', 'orange'] Copied Fruit Basket: ['apple', 'banana', 'grapes', 'mango', 'orange'] Explanation: In the above example, we have used the copy() method to create a shallow copy of the given list. Next TopicPython Tuples |
We request you to subscribe our newsletter for upcoming updates.