Overview
- The removesuffix() method of bytearray removes a given suffix from a bytearray object. The resultant sequence is returned as a new bytearray object.
- The suffix is any bytes-like object. For example, the suffix can be a bytes or a bytearray object.

Example
# Example Python program that removes
# a suffix from a bytearray.
# Bytearray creation
text = bytearray(b"The sands were dry as dry")
# Remove the suffix from the bytearray
suffix = b" as dry"
suffixRemoved = text.removesuffix(suffix)
print("Text after removing the suffix:")
print(suffixRemoved)Output
Text after removing the suffix:
bytearray(b'The sands were dry')