Google News
logo
Python Program to Remove the last item
To remove the last item from a list in Python, we can use the `pop()` method with the index `-1`. Here's an example :
Program :
my_list = [1, 2, 3, 4, 5]
my_list.pop(-1)
print(my_list)  # Output: [1, 2, 3, 4]
Output :
[1, 2, 3, 4]
Alternatively, we can also use the `del` keyword with the same index :
Program :
my_list = [1, 2, 3, 4, 5]
del my_list[-1]
print(my_list)  # Output: [1, 2, 3, 4]
Output :
[1, 2, 3, 4]
Both of these methods will remove the last item from the list.