Python - Print list after removing element at given index Last Updated : 15 Jan, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will explore different ways to remove an element from a list at a given index and print the updated list, offering multiple approaches for achieving this.Using pop()pop() method removes the element at a specified index and returns it. Python li = [10, 20, 30, 40, 50] index = 2 li.pop(index) print(li) Output[10, 20, 40, 50] Explanation:pop() method removes the element at the specified index (2 in this case), which is 30, from the list li.After the pop(), the list li is updated to [10, 20, 40, 50], with the element at index 2 removed. Using List SlicingWe can use list slicing to remove an element by excluding the element at the given index. Python li = [10, 20, 30, 40, 50] index = 2 li = li[:index] + li[index+1:] print(li) Output[10, 20, 40, 50] Explanation:This code creates a new list by concatenating two slices of the original list l: one from the beginning up to index (excluding the element at index), and the other from index+1 to the end of the list.As a result, the element at index 2 (which is 30) is removed, and the updated list is [10, 20, 40, 50]. Using del Keyworddel keyword can be used to delete an element at a specific index. Python li = [10, 20, 30, 40, 50] index = 2 del li[index] print(li) Output[10, 20, 40, 50] Explanation:del statement removes the element at the specified index (2 in this case), which is 30, from the list li.After using del, the list li is updated to [10, 20, 40, 50], with the element at index 2 removed.Using List ComprehensionList comprehension can be used to create a new list excluding the element at the specified index. Python l = [10, 20, 30, 40, 50] index = 2 l = [l[i] for i in range(len(l)) if i != index] print(l) Output[10, 20, 40, 50] Explanation:This code uses list comprehension to create a new list by iterating over the indices of the original list li and including only those elements where the index is not equal to 2.As a result, the element at index 2 (which is 30) is excluded, and the updated list is [10, 20, 40, 50]. Comment More infoAdvertise with us Next Article Remove first element from list in Python S Striver Follow Improve Article Tags : Misc Python python-list Python list-programs Practice Tags : Miscpythonpython-list Similar Reads Remove Last Element from List in Python 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, le 2 min read Remove Last Element from List in Python 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, le 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 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 Like