# Bytes Bytearray bytes/bytearray can contain numbers between 0 and 255 ## Overview | What | How | | - | - | | `bytes` | immutable byte sequence | | `bytes(10)` | create bytes of length 10 | | `bytes[0]` | get first byte | | - | - | | `bytearray` | mutable byte sequence | | `bytearray(10)` | create bytearray of length 10 | | `bytearray[0]` | get first byte | | - | - | | *bytes from bytearray* | `bytes(bytearray)` | | *bytearray from bytes* | `bytearray(bytes)` | | *copy from bytearrayOrBytes* | `bytearray(bytearrayOrBytes)` | handle both with one method: ```python def method(data: bytearray | bytes): # accept both types mydata = bytearray(data) # copy of bytes or bytearray ```
