Bytearray Methods
bytearray.remove()
Remove the first occurrence of the specified integer byte value, not the byte at that index. A missing value or an integer outside 0–255 raises ValueError. A bytes object or other unsupported type raises TypeError. Use pop() to remove by position and retrieve the removed value. An active buffer export blocks removal of a present byte because length would change.
Formal Syntax & Structure
python syntaxpython
data.remove(value, /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| value | int | SupportsIndex | Integer byte value to remove, 0–255. |
Return Value
None
None; modifies the existing buffer.
Working Example
Example Snippetpython
data = bytearray(b"ABAC")print(data.remove(65))print(data)try: data.remove(90)except ValueError: print("missing")