How to Remove First Element from List in Python?
Here, I will show you how to works python list delete first element. This article will give you simple example of python list remove first element. I would like to share with you python list remove one element. you will learn python list remove first n elements.
In this example, I will give you two examples. one using "del" in python and another using "pop" function of array. we will pass first key and it will remove first element from array in python. so let's see below examples.
You can use these examples with python3 (Python 3) version.
let's see below simple example with output:
myArray = ['one', 'two', 'three', 'four', 'five'] # Remove First Element myArray.pop(0) print(myArray)
['two', 'three', 'four', 'five']
myArray = [1, 2, 3, 4, 5, 6] # Remove First Element del myArray print(myArray)
[2, 3, 4, 5, 6]
I hope it can help you...
We are Recommending you
- Python List Remove Element by Index Example
- How to Get All Files from Directory in Python?
- Python Delete Files Matching Pattern Example
- Python Delete Folder and Files Recursively Example
- Python Delete Files with Specific Extension Example
- Python Delete Directory if Exists Example
- Python Post Request with Basic Authentication Example
- Python Get First Date of Last Month Example
- Python Get First Date of Next Month Example
- Python Create Zip Archive from Directory Example
- How to Compare Two Dates in Python?
- How to Check if Today is Saturday or not in Python?