Pythonexit code > 0

ValueError: not enough values to unpack

$ValueError: not enough values to unpack (expected 3, got 2)

Analysis

You tried to unpack a sequence (list/tuple) into variables, but the number of items didn't match.

Common Triggers

  • Returning fewer values from a function than expected.
  • Iterating over a list of lists where one inner list is too short.

Debug Checks

  • $Print the length of the sequence: print(len(seq)).

Resolution

1
Adjust the number of variables to match.
2
Use star unpacking: a, *b = seq.