Bytearray
A bytearray is a mutable sequence of integers in the range 0 to 255, used to store and manipulate binary data. It is similar to the immutable bytes type, but supports in-place modification and dynamic resizing. Like other sequences, it supports iteration, indexing, and slicing.
A bytearray can be created in several ways. Calling bytearray() produces an empty buffer. Passing an integer
Bytearrays are mutable and support common sequence operations. Elements can be assigned individual values, for example
Conversions and interoperability are straightforward. A bytearray can be converted to immutable bytes with bytes(b) or
Notes: all stored values must be integers in the range 0–255; attempting to assign or append values