If I understood the question correctly, you can use the slicing notation to keep everything except the last item:

record = record[:-1]

But a better way is to delete the item directly:

del record[-1]

Note 1: Note that using record = record[:-1] does not really remove the last element, but assign the sublist to record. This makes a difference if you run it inside a function and record is a parameter. With record = record[:-1] the original list (outside the function) is unchanged, with del record[-1] or record.pop() the list is changed. (as stated by @pltrdy in the comments)

Note 2: The code could use some Python idioms. I highly recommend reading this:
Code Like a Pythonista: Idiomatic Python (via wayback machine archive).

Answer from sebastian on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-list-pop-method
Python List pop() Method - GeeksforGeeks
July 17, 2026 - Explanation: a.pop() removes and returns the last element of the list and removed value is stored in val.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ remove-last-element-from-list-in-python
Remove Last Element from List in Python - GeeksforGeeks
July 12, 2025 - This is often done to update or ... last element from list in python, let's explore it one by one. pop() method removes and returns the last element of a list....
Discussions

python - How to delete last item in list? - Stack Overflow
I have this program that calculates the time taken to answer a specific question, and quits out of the while loop when answer is incorrect, but i want to delete the last calculation, so i can call ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - Removing last list element by popping - Stack Overflow
I have the following piece of Python code where I am trying to empty out list A by removing one element at a time starting from the end. I cannot seem to reduce the list to an empty one and I would like to know why not. Any insight would be extremely appreciated. ... Note that lists have a clear method: A.clear(). If you're trying to consume the list like a job queue, then consider a while loop instead while A: item = A.pop... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How do I remove an element from the end of a list without returning the value? (Python)
Can't you just ignore the returning value...? More on reddit.com
๐ŸŒ r/learnprogramming
5
2
April 30, 2021
Neater way to access the last n elements in a vec?

You can use an endless range:

let vec = vec![1, 2, 3, 4, 5];
println!("Remaining: {:?}", &vec[2..]);

Prints: "Remaining: [3, 4, 5]"

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=8b1a03af4ae475b294030f3d5d43b5ad

More on reddit.com
๐ŸŒ r/learnrust
14
18
January 13, 2020
๐ŸŒ
Hyperskill
hyperskill.org โ€บ university โ€บ python โ€บ pop-in-python
Pop() in Python
October 14, 2025 - The Python pop() function deletes an element from a list at an index or if no index is specified, the last item. It comes in handy for removing items, from a list without changing the order of elements.
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ python โ€บ standard library โ€บ list โ€บ pop()
Python List pop() - Remove Last Item
November 5, 2024 - The pop() method in Python is a versatile function used to remove an item from a list. Specifically, it's highly efficient when you need to delete the last item of a list, but it can also be adjusted to remove an item from any position.
๐ŸŒ
FavTutor
favtutor.com โ€บ blogs โ€บ remove-last-element-from-list-python
Remove Last Element from List in Python | FavTutor
October 12, 2023 - In this article, we discussed three approaches, along with their pros and cons, using which we can delete the last element of a list. However, the pop() function is the most recommended and widely accepted method to delete an element from the list.
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ python โ€บ pop()
Python Pop Method: Essential Data Manipulation techniques
In Python, pop() is a list method that removes and returns an element of a list. With an argument, pop() removes and returns the item at the specified index (starting from 0). Without an argument, pop() removes and returns the last item of the list.
Find elsewhere
๐ŸŒ
Linux Hint
linuxhint.com โ€บ pop-last-list-element-python
Linux Hint โ€“ Linux Hint
May 19, 2023 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ python-get-last-element-in-list
Python: Get Last Element in List
March 2, 2023 - It is the simplest and most Pythonic way to solve this problem. On the other hand, if you need to remove the last element, as well as access it, then you should probably go with the pop() method, which is the built-in method for performing exactly this behavior. Follow to keep up with AI and ...
๐ŸŒ
How to Use Linux
howtouselinux.com โ€บ home โ€บ 3 ways to remove the last element from list in python
3 ways to remove the last element from list in Python - howtouselinux
October 9, 2025 - This function removes and returns the last element from a list. The syntax for this function is as follows: list.pop() For example, if we have a list of integers called my_list, we can remove the last element by using the following code:
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ methods โ€บ list โ€บ pop
Python List pop() (with Code Visualization)
The list pop() method removes and returns the item at a specified index. If no index is specified, pop() removes and returns the last item. Here's a quick example:...
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ python โ€บ get last element of list in python
How to Get Last Element of List in Python | Delft Stack
February 15, 2024 - In this tutorial, we will discuss methods to get the last element of a list in Python. The pop() function can be used to get the last element of a list. The pop() function by default returns the last element of the list and removes that element ...
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ python-list-pop-how-to-pop-an-element-from-a-array
Python list.pop() โ€“ How to Pop an Element from a Array
February 9, 2023 - Without passing the index of an element as a parameter to the pop() method in the list above, the last element in the list was removed.
๐ŸŒ
Techie Delight
techiedelight.com โ€บ home โ€บ python โ€บ remove the last element from a python list
Remove the last element from a Python list | Techie Delight
July 7, 2026 - This post will discuss how to remove the last element from a list in Python... The simplest approach is to use the list's `pop()` function, which removes an element present at the specified position in the list.
๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ python-remove-item-from-list
How to Remove an Item from a List in Python: A Full Guide | DataCamp
August 1, 2024 - If you do not specify the index for the element to remove from the list, the pop() function will remove the last item in the list by default. If you want to remove the first item from a list in Python, you will specify the index as 0 using the ...
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ python โ€บ python list remove last element
Python List Remove Last Element - Spark By {Examples}
May 31, 2024 - How to remove the last element/item from a list in Python? To remove the last element from the list, you can use the del keyword or the pop() method.
๐ŸŒ
Finxter
blog.finxter.com โ€บ home โ€บ learn python blog โ€บ python slice remove first and last element from a list
Python Slice Remove First and Last Element from a List - Be on the Right Side of Change
October 8, 2022 - To remove the last element of a Python list, you can use the list.pop() method without argument. You can call both to remove the first and the last elements if the list has at least two elements.
๐ŸŒ
PythonHow
pythonhow.com โ€บ how โ€บ get-the-last-element-of-a-list
Here is how to get the last element of a list in Python
To get the last element of a list in Python, you can use the index -1.You can also use the pop() method to remove and return the last element of a list. This method removes the element from the list, so if you want to keep the original list intact, you can use the slicing syntax to get a copy ...
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_list_pop.asp
Python List pop() Method
Python Examples Python Compiler ... Python Study Plan Python Interview Q&A Python Training ... The pop() method removes the element at the specified position....