- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Internal working of the list in Python
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
To Continue Learning Please Login
Login with Google