Convert bytes ↔ bytearray ↔ str ↔ list Dry Run in PYTHON

Convert bytes ↔ bytearray ↔ str ↔ list is an interactive PYTHON dry run visualizer from the Bytes programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Convert bytes ↔ bytearray ↔ str ↔ list Program Code

# conversions
text = "Python"
b = text.encode("utf-8")           # str → bytes
ba = bytearray(b)                  # bytes → bytearray
b2 = bytes(ba)                     # bytearray → bytes
s = b2.decode("utf-8")             # bytes → str

lst = list(b)                      # bytes → list of ints
b3 = bytes(lst)                    # list → bytes

print("original string:", text)
print("bytes:", b)
print("bytearray:", ba)
print("bytes back:", b2)
print("decoded string:", s)
print("list of ints:", lst)
print("bytes from list:", b3)

View the complete Bytes programs page.

Program Console Convert bytes ↔ bytearray ↔ str ↔ list Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.