Pybites Logo Rust Platform

Mini Parser

Medium +3 pts

🎯 In Python, parsing a simple value might use json.loads or manual checking:

import json def parse_primitive(text): text = text.strip() if text in ("true", "false"): return text == "true" if text == "null": return None return int(text) # raises ValueError on bad input

Simple, but error handling is implicit — int() raises, json.loads raises, and callers need to know what exceptions to catch.

This exercise combines everything from the intro track: enums with data, pattern matching

Login to see the full exercise.