Python Practice › List Programs › Program 25
Remove by index with pop()
Write a Python program to remove an element at a given index with pop().
Input
["a", "b", "c", "d"], index 2
Output
c ['a', 'b', 'd']
Approach
pop(index)removes and returns the item.
Solution
items = ["a", "b", "c", "d"]removed = items.pop(2)print(removed, items)Output
c ['a', 'b', 'd']
Learn the concept
New to this topic? Read the lesson, then come back.