Print("The type of",list1,"is:",type(list1)) List2=] # creating a list of different values An example of creating a list is shown below.Įxample of creating a list in Python list1= # creating an empty list It can contain any type of value including lists. Creating Python listsĮlements in a list are enclosed with square brackets (‘’) with each separated by comma. We will start with creation and look into many other operations that can be done on lists now. These are mainly used in situations where there is a need to access the data frequently, which can be done easily using indexing. These store the data in a continuous manner in the memory. Lists are the containers of values of different data types. In the next few sections we will discuss the built-in data structures in detail. Based on these features, these are used in suitable situations. Python User-defined data structures: These data structures are the ones built using the built-in data structures and have their own properties. Python Built-in data structures: These are the data structures that come along with Python and can be implemented same as primitive data types like integers, etc.
These can be mainly classified into two types:ġ.
To suit different uses, there are different data structures in Python. Let’s begin! Introduction to Data Structures in PythonĪs discussed above, the data structures are the organizers and storers of data in an efficient manner so that they can be modified and accessed in the future. We will discuss the built-in data structures in this article along with some light on the derived ones. In a program, all these are managed with the help of the data structures. It includes the bill of the things bought from grocery shops, the whatsapp text with your contacts, etc.