What is list in python??

In python, list is a type of array or a container where you can store different types of data. The elements stored in a list are ordered and indexed in a definite sequence and indexing is done with 0.

It is mutable, heterogeneous and sequential data structure in python, which supports efficient insertion, appending , deletion and concatenation.

A list can be created by placing the elements inside the square brackets [] like


which can perform append(x), extend(iterable), insert(ix), remove(x), pop([i]), clear(), etc. operations.

Unlike the variables, same lists do not have same memory address. The following examples illustrate the same.

List Comprehensions :

List Comprehension provide a short and elegant way to create a list.

This is the basic syntax :

List=[expression  for_loop  conditions]

For example:

Lists limitations:

In python , lists are efficient data structures and list comprehension also make them to easy to construct and manipulate. But there are certain limitations of lists such as it do not support vectorized operations like element wise addition, dot product ,cross product, etc.

A numpy array module is used to perform such operations which is more efficient and convenient.

However there are certain features which a list perform and numpy.array  do not , such as heterogeneous elements , adding and removing elements in same list , etc.



Codec Networks provides IT Trainings from EC Council CEH ECSA, LPT, CHFI, Network Security, Penetration Testing, ISACA, ISC2, PECB ISO 27001LA LI, Cisco Networking CCNA CCNP, Linux Administration RHCE, Prog Languages JAVA, Advanced Java, android development. We also offer B2B Industry Solutions and Services in IT | Information|Cyber Security in Delhi NCR India.

View all posts by