Skip to the workspace
Pebellslearn by building

Python syntax & reference

Find the form you need, compare how it behaves, and open the complete explanation when you need more depth.

Python 3.10+ syntax; individual entries identify newer features. Browser exercises use the configured Python runner.

1 matching syntax entry

Text versus bytes

Learn in depth →

str contains Unicode text; bytes contains integer byte values. Encoding and decoding cross that boundary.

text.encode("utf-8"); data.decode("utf-8")

Example

text = "café"
data = text.encode("utf-8")
print(len(text), len(data), data.decode("utf-8"))

Result

4 5 café

Watch for: The encoding must match the data. Ignoring decoding errors can silently lose information.

Practise this topic →
Complete explanation index (91 lessons indexed)

Unicode, str and bytes

Technical sources and review date

Original Pebells examples. Reviewed 2026-10-28.

Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.