# Internal working of the list in Python

PythonServer Side ProgrammingProgramming

In this tutorial, we will learn about the internal working of the list in Python 3.x. Or earlier. We will also look at the object and frame formation when we write a python statement at each step.

Initializing the list: This means that we are creating a list with some elements.

>>> lis=[1,2,3,4]

Here list variable is declared in the global frame which is referring to a list object as shown above

Now let’s see what happened when we append the element in the list.

>>> lis.append(8)

Here the element is added at the end and the size of the list is increased by 1.

Now let’s observe how we can delete a specific element from the list.

>>> lis.remove(2)

When an element is deleted from the list all the characters are shifted to the consecutive left position.

Now we declare a new variable and reference it to sliced part of the list.

>>> p=lis[0:3]

Lastly, we consider deleting the element at a specific index

>>> del p[0]

## Conclusion

In this article, we learned about the Internal working of the list in Python 3.x. Or earlier

Published on 29-Aug-2019 11:34:57