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 |
| ||||
Related |
.insert() .append() .reverse() .index() |
Updated on Mon Sep 21 15:53:25 2020.
If you see any errors or have comments, please let us know.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License