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 & Methods:
Some examples of python list functions & methods are as follows :
- index :- It returns the index of first occurrence of an element in the list.
- count :- It counts a total number of occurrence of an element in the list.
- append :- It adds a new element at the end of the list.
- extend :- It adds all the element of iterable object like list,string at the end of the list.
- insert :- It insert an element at the specific index of the given list.
- remove :- It removes the first occurrence of an element from the list.
- pop :- It remove and return the last element of the list.
- sort :- It sorts the elements of the given list.
- reverse :- It reverse the order of elements in the given list.
- clear :- It removes all the elements of the list.
- copy :- It creates the shallow copy of the given list.
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.