Python List Functions & Methods – Python Tutorial

1 year ago Lalit Bhagtani 0

In Python, Objects have built-in methods inside it, which can be used to perform actions on the object itself. We can call methods of any object by putting period after object variable and then the method name.

Syntax:    objectVariable.methodName( parameters.. )

                  objectVariable :  variable containing object. 

                  methodName :   name of the method, which we like to execute.

                  parameters :      extra parameter ( 0 or more ) pass into the method.

Python List Functions

Python List Functions & Methods: 

Some examples of python list functions & methods are as follows :

  1. index :- It returns the index of first occurrence of an element in the list.
  2. count :- It counts a total number of occurrence of an element in the list.
  3. append :- It adds a new element at the end of the list.
  4. extend :- It adds all the element of iterable object like list,string at the end of the list.
  5. insert :- It insert an element at the specific index of the given list.
  6. remove :- It removes the first occurrence of an element from the list.
  7. pop :- It remove and return the last element of the list.
  8. sort :- It sorts the elements of the given list.
  9. reverse :- It reverse the order of elements in the given list.
  10. clear :- It removes all the elements of the list.
  11. copy :- It creates the shallow copy of the given list.

References :-

  1. List Functions & Methods Docs

That’s all for Python List Functions & Methods. If you liked it, please share your thoughts in comments section and share it with others too.