In this Python for Testers Tutorial we will learn about List methods in Python. List data type methods in Python help us to manipulate list elements. We can use python list functions to add an item to the end of the list, insert an item at a given position, remove the first item from the list and many more operations can be done with built in list methods of Python. In this Python Tutorial we will learn following list methods.
✔️ list.append – Add an item to the end of the list.
✔️ list.insert – Insert an item at a given position.
✔️ list.remove – Remove the first item from the list whose value is equal to x.
✔️ list.pop – Remove the item at the given position in the list, and return it.
✔️ list.index – Return zero-based index in the list of the first item whose value is equal to x.
✔️ list.count – Return the number of times x appears in the list.
✔️ list.sort – Sort the items of the list in place.
✔️ list.reverse – Reverse the elements of the list in place.
✔️ list.copy – Return a shallow copy of the list.
✔️ list.clear – Remove all items from the list.