POP()

The pop() method removes and returns an element at a specified index. If you provide an index, the item at that position is removed. If no index is supplied, pop() defaults to removing the last element in the list. This method is useful when you need both the removal and the value itself.

colors = ['black', 'blue', 'white', 'cyan', 'yellow', 'green']
intInput = int(input())
colors.pop(intInput)
print(colors)

Last updated