04-Nov-2022
.
Admin
Hi Dev,
Now, let's see article of Remove Last Element from List in Python Example. I’m going to show you about How to Remove Last Element From Array in Python. let’s discuss about Numpy List Drop One Element. you'll learn Python List Remove Last n Elements. Here, Creating a basic example of Python List Remove One Element.
In this example, I will give you two examples. one using "del" in python and another using "pop" function of array. we will pass last key and it will remove last element from array in python. so let's see below examples.
so let's see following examples with output:
Example 1:
main.py
myArray = ['one', 'two', 'three', 'four', 'five']
# Remove First Element
myArray.pop()
print(myArray)
Output:
['one', 'two', 'three', 'four']
Example 2:
main.py
myArray = [1, 2, 3, 4, 5, 6]
# Remove First Element
del myArray[-1]
print(myArray)
Output:
[1, 2, 3, 4, 5]
#Python