Showing posts with label list in python. Show all posts
Showing posts with label list in python. Show all posts

Tuesday, May 26, 2020

,

build-in function for list in python and array method

These all are the build-in function which is used to manipulate the list in the python.

Python build-in list function and array method
build-in function for list in python and array method

Python List append Method:-

append() function in python use to add an element at the end of the list.

Syntax : - 

list.append(elmnt) 

clear() method in Python:-

clear() function in python programming helps you to remove all the elements from the list

Syntax : - 

list.clear()

copy() method in list:-

As its name says copy() function gives a copy of the specified list.

Syntax : - 

list.copy()

count() method in python list:-

count() function in python count the number of elements in a specified value and return it.

Syntax : - 

list.count(value)

extend() method in python list:-

extend() method of python list uses to add any specified iterable at the end of the current list.

Syntax : - 

list.extend(iterable)

index() method in python:-

index() method of list returns the address of the first occurrence of the specified value in python.

Syntax : - 

list.index(elmnt)

insert() function in python:-

insert() function uses to insert an element at the specified position in the python list.

Syntax : - 

list.insert(pos, elmnt)

pop() function in python list:-

pop() function uses as it is used in the data structure to remove an element from a list at the specified position so it uses the same in python to remove any element from the python list.

Syntax : - 

list.pop(pos)

the default value is -1 which gives the last element of a list.

remove() function in python list:-

remove() method of python list removes the first occurrence of the element at the specified value.

Syntax : - 

list.remove(elmnt)

reverse() method in python list:-

reverse() method of python list helps to reverse the sorting order of the element in the list.

Syntax : - 

list.reverse()

sort() method:-

sort() method of python list helps to sort the list in ascending by default. 

Syntax : - 

list.sort(reverse=True|False, key=myFunc)