Open In App

Remove Last Element from List in Python

Last Updated : 12 Jul, 2025
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report

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)

Output
['Geeks', 'For']

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)

Output
['Geeks', 'For']

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)

Output
['Geeks', 'For']

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)

Output
['Geeks', 'For']

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:


Article Tags :
Practice Tags :

Similar Reads