# ValueError: too many values to unpack (expected 2)

**Code:** `unpack error` · **Category:** Python · **Seen on:** Python

Tuple unpacking got more (or fewer) values than variables on the left.

## 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

1. Use for k, v in d.items()
2. split with maxsplit: s.split(",", 1)
3. Use star-unpacking: first, *rest = parts

## Detailed fix by platform

### Python

1. `key, value = line.split("=", 1)`

## How to diagnose

1. **Values** — Expected vs actual count
2. **Source** — What is being unpacked?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/python/valueerror-too-many-values-to-unpack)
