Remove Last Element from List in Python
Last Updated :
12 Jul, 2025
Removing the last element from a list means deleting the item at the end of list. This is often done to update or shorten the list, discard unwanted data or manage memory in certain programs.
Example:
lnput: [1,2,3,4,5]
Output: [1,2,3,4]
There are many ways to remove last element from list in python, let's explore it one by one.
Using pop() method
pop() method removes and returns the last element of a list. It allows the users to directly modifies the original list and is useful when you need to both update the list and use the removed item.
Example:
Python
a = ["Geeks", "For", "Geeks"]
a.pop()
print(a)
Explanation: a.pop() removes 'Geeks' from the list a.
Using del operator
del operator allows removal of list elements by index. To delete the last element, del list[-1] is used, which directly modifies the original list by removing its last item without returning it.
Example:
Python
a = ["Geeks", "For", "Geeks"]
del a[-1]
print(a)
Explanation: del a[-1] removes the last element from the list by targeting its index i.e 'Geeks'.
Using slicing
Slicing allows accessing a portion of a list using index ranges. To remove the last element, list[:-1] is used, which returns a new list containing all elements except the last one. It does not modify the original list.
Example:
Python
a = ["Geeks", "For", "Geeks"]
a= a[:-1]
print(a)
Explanation: a = a[:-1] creates a new list containing all elements of a except the last one.
Using List comprehension
List comprehension is a concise way to build new lists. To remove the last element, it can use slicing like [x for x in list[:-1]], which creates a new list excluding the last item, keeping the original list unchanged.
Example:
Python
a = ["Geeks", "For", "Geeks"]
a = [x for x in a[:-1]]
print(a)
Explanation:
- a[:-1] creates a new list with all elements except the last one.
- [x for x in a[:-1]] uses list comprehension to iterate over that sliced list and build a new one.
Related Articles:
Similar Reads
Remove Multiple Elements from List in Python In this article, we will explore various methods to remove multiple elements from a list in Python. The simplest way to do this is by using a loop. A simple for loop can also be used to remove multiple elements from a list.Pythona = [10, 20, 30, 40, 50, 60, 70] # Elements to remove remove = [20, 40,
2 min read
Remove Multiple Elements from List in Python In this article, we will explore various methods to remove multiple elements from a list in Python. The simplest way to do this is by using a loop. A simple for loop can also be used to remove multiple elements from a list.Pythona = [10, 20, 30, 40, 50, 60, 70] # Elements to remove remove = [20, 40,
2 min read
Remove first element from list in Python The task of removing the first element from a list in Python involves modifying the original list by either deleting, popping, or slicing the first element. Each method provides a different approach to achieving this. For example, given a list a = [1, 2, 3, 4], removing the first element results in
2 min read
Remove first element from list in Python The task of removing the first element from a list in Python involves modifying the original list by either deleting, popping, or slicing the first element. Each method provides a different approach to achieving this. For example, given a list a = [1, 2, 3, 4], removing the first element results in
2 min read
How to Remove Item from a List in Python Lists in Python have various built-in methods to remove items such as remove, pop, del and clear methods. Removing elements from a list can be done in various ways depending on whether we want to remove based on the value of the element or index.The simplest way to remove an element from a list by i
3 min read
Remove falsy values from a list in Python Removing falsy values from a list filters out unwanted values like None, False, 0 and empty strings, leaving only truthy values. It's useful for data cleaning and validation.Using List ComprehensionList comprehension is a fast and efficient way to remove falsy values from a list . It filters out val
1 min read