Remove the last N elements of a list
list, python
Solution
if you wish to remove the last n elements, in other words, keep first len - n elements:
lst = lst[:len(lst)-n]
Note: This is not an in memory operation. It would create a shallow copy.
Problem
Is there a a better way to remove the last N elements of a list. ``` for i in range(0,n): lst.pop( ) ```