Python Remove First Element from List Example

Published On: 03/11/2022 | Category: Python


Hi Guys,

Today, how to remove first element from list in python is our main topic. you'll learn python list remove first element. we will help you to give example of python list remove one element. you will learn python list delete first element.

I'll offer you two examples in this case. one employing Python's "del" function and another using an array's "pop" function. we will pass first key and it will remove first element from array in python. so let's see below examples.

So let's see bellow example:

Example 1

main.py
myArray = ['one', 'two', 'three', 'four', 'five']
  
# Remove First Element
myArray.pop(0)
  
print(myArray)
Output
['two', 'three', 'four', 'five']

Example 2

main.py
myArray = [1, 2, 3, 4, 5, 6]
    
# Remove First Element
del myArray[0]
    
print(myArray)
Output
[2, 3, 4, 5, 6]

It will help you....

Happy Pythonic Coding!