ValueError: too many values to unpack (expected 2)
Tuple unpacking got more (or fewer) values than variables on the left.
Seen on:
Python
Meaning
Common when iterating a dict without .items(), splitting strings with more separators than expected, or functions returning a different number of values.
Common causes
- for k, v in dict: (missing .items())
- line.split(",") returning more parts
- Function returns a different tuple size
⚡ Quick fix
- Use for k, v in d.items()
- split with maxsplit: s.split(",", 1)
- Use star-unpacking: first, *rest = parts
Detailed fix by platform
Python
key, value = line.split("=", 1)
How to diagnose
- Values — Expected vs actual count
- Source — What is being unpacked?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026