
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
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
- Related Articles
- Internal working of Python
- Internal working of Set in Python
- Internal Working of HashMap in Java
- The internal working of the ‘foreach’ loop in PHP
- Internal working of Set/HashSet in Java
- What is the difference between working of append and + operator in a list in Python?
- Demonstrate the working of violin plots in Python?
- How to flush the internal buffer in Python?
- Modification not working for both internal table and control table in SAP ABAP
- Internal Python object serialization (marshal)
- Python Pandas - Get the timedelta in nanoseconds for internal compatibility
- Working with Images in Python?
- Convert list of string to list of list in Python
- Convert list of tuples to list of list in Python
- Working with PDF files in Python?
