Built-in Functions
bytearray()
Create a mutable sequence of bytes.
bytearray(source=b"")
bytearray() stores byte values from 0 through 255. Unlike bytes, you can change individual byte values after creating it.
Arguments
Parameters
| Name | Description |
|---|---|
| source | Optional bytes, an iterable of integers, a string with an encoding, or a size. |
Result
Returns
A new mutable bytearray object.
Run it
Try it
Run it and change it
letters = bytearray(b"cat") letters[0] = 67 print(letters)
Output
Press Run to see what it prints.