Instagram
youtube
Facebook
Twitter

Python Program to Delete Element from List at Given Index

A Python Program to Delete Element from List at Given Index

Code Description:
This Python program deletes the element at index 4 from a list and prints both the deleted element and the updated list.**
Explanation:

• A list my_list is defined with 10 elements.
• The pop(4) function removes the element at index 4 (which is 55) and stores it in new_list.
• The removed element is printed:
"This is my delete element: 55"
• The updated list is printed after deletion:
[11, 22, 33, 44, 66, 77, 88, 99, 100]

 

Program:

my_list = [11,22,33,44,55,66,77,88,99,100]

new_list = my_list.pop(4)

print("This is my delete element: ",new_list)

print('this is update list: ',my_list)