Source Code:
(back to article)
# Initialize the list my_list = [1, 2, 3, 4, 5] # Remove the element at index 2 (which is 3) removed_element = my_list.pop(2) # Print the list and the removed element print(my_list) # [1, 2, 4, 5] print(removed_element) # 3
Result:
Report an issue