List methods in python

Here are a collection of all list methods in python with examples which will help you understand the list methods in python. List is a collection which is ordered and changeable. In Python lists are written with square brackets.

List methods in python

Python has a set of built-in methods that you can use on lists/arrays. below are the list of all List method of python programming language with example.

Output:

Python List Methods with description

Following are the collection of Python List Methods/array.

Python List Methods
append() – Add an element to the end of the list
extend() – Add all elements of a list to the another list
insert() – Insert an item at the defined index
remove() – Removes an item from the list
pop() – Removes and returns an element at the given index
clear() – Removes all items from the list
index() – Returns the index of the first matched item
count() – Returns the count of number of items passed as an argument
sort() – Sort items in a list in ascending order
reverse() – Reverse the order of items in the list
copy() – Returns a shallow copy of the list

Data types in the Python programming language

There are four collection data types in the Python:

  • List – A collection which is ordered and changeable.
  • Tuple is a collection which is ordered and unchangeable.
  • Set is a collection which is unordered and unindexed.
  • Dictionary is a collection which is unordered, changeable and indexed.

List methods in python – Examples

 

Recommended Posts:


Editorial Staff

Editorial Staff at FreeWebMentor is a team of professional developers leads by Prem Tiwari

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Solved Programs