Python — Lists


Lists are used to store multiple items in a single variable. Lists are ordered collections of objects/elements. the list is mutable. the list can have heterogeneous data types.

append — syntax: <list name>.append(<object>)

extend —syntax: <list name>.append(<list of objects>)

count — syntax: <list name>.count(<object>)

copy — syntax: <New list> = <list name>.copy()

pop — syntax: <list name>.pop( *index )

remove — syntax: <list name>.remove(<object>)

reverse — syntax: <list name>.reverse()

index — syntax: <list name>.index(<object>,*s pos ,*e pos)

insert — syntax: <list name>.insert(index , <object>)

sort — syntax: <list name>.sort()

clear — syntax: <list name>.clear()


Append is used to append/add the object to the end of the list.


Extend is used to add multiple objects to the end of the list.


The count function is used to find the number of occurrences of the value/object.


The copy function is used to copy the Elements of the list.


the pop function is used to remove an item at the specified index from the list.


Remove is used to delete a particular element/object from the list only once.


Reverse helps us to reverse the list.


The index function is used to get the index of the value/object. we can also check where the Object is present in a certain range of indexes or we can skip indexes using start_position and stop search using end position.

Here *(-1) is Reverse indexing


Insert is used to insert an object at a certain position, Insert takes 2 arguments those are index and Object.


Sort helps to sort the list in both ascending and descending order, with the argument reverse <defult = False> that is ascending order. sort changes the original list.


Clear as the name says this function is used to clear the objects inside the list.

Stay tuned….



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vasu Devan S

Vasu Devan S


Data Scientist aspirant | Machine learning | SQL | Web scraping|Data mining|Statistics |Python |Pandas|Advanced Excel