Overview:
- The pop() method of bytearray in Python removes an element from the last position. By default, the index parameter assumes the value of -1 which denotes the last position.
- If a value is passed to the parameter index, then the element from the given index is removed.
Example:
|
# Example Python program that removes an element from # Remove a byte from the last position # Remove two bytes continously from the first position |
Output:
| After pop() removing last element: bytearray(b'A sailor went to sea, sea, se') After pop() removing first two elements: bytearray(b'sailor went to sea, sea, se') |