Python list object methods

The python list has a number of methods or functions to carry out different activities or action.All the known methods of list are given below.

Name Function
append(x) Add an item to the end of the list
extend(iterable) Extend the list by appending all the items from the iterable
insert(i, x) Insert an item at a given position.
remove(x) Remove the first item from the list whose value is equal to x
pop([i]) Remove the item at the given position in the list, and return it
clear() Remove all items from the list
index(x[, start[, end]]) Return zero-based index in the list of the first item whose value is equal to x
count(x) Return the number of times x appears in the list.
sort(key=None, reverse=False) Sort the items of the list in place.
reverse() Reverse the elements of the list in place
copy() Return a shallow copy of the list

Visit each of the link to know more abut the function.

The functions given above are to be called upon a list object.The format of calling them is:
A code example is given below.

>>> ls=[23 , 4 , 90 ,1637 , 67]
>>> ls.reverse() #reverse() method called
>>> ls
[67, 1637, 90, 4, 23] #the values are reversed