Name

.pop()

Examples
a = [1, 2, 3, 4]
print(a)
a.pop()    # Removes the last element of the list.
print(a) # Prints: [1, 2, 3]
a.pop(1)   # Remove the element at index 1 of the list. 
print(a) # Prints: [1, 3]
Description This method removes and returns an element of the list from the given index. If no index is given, the last element is removed and returned.
Syntax
a.pop()
a.pop(i)
Parameters
aList from which to pop.
iIndex of element to pop.
Related .insert()
.append()
.reverse()
.index()

Updated on Tue Feb 27 14:07:12 2024.

If you see any errors or have comments, please let us know.